This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove verify_no_unreachable_blocks


On Thu, 23 Aug 2018, Tom de Vries wrote:

> On 08/23/2018 01:18 PM, Richard Biener wrote:
> > This removes verify_no_unreachable_blocks and implements checking
> > for unreachable blocks in inverted_post_order_compute by simply
> > looking if we reach a block without predecessors that is not the
> > entry block.
> > 
> 
> I think that doesn't detect unreachable cyles: say you have blocks A and
> B, and A -> B -> A.

Ah, true.  Bah, I guess I can use some other flag in my pass.

> > This solves a problem I ran into when (ab-)using BB_REACHABLE
> > in a pass and I got comparison failues because of -fchecking vs.
> > -fno-checking.  It also should speed up checking builds.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu.
> > 
> > Tom, does this make sense?
> > 
> 
> The intent of the check I added was to verify the assumption stated in
> the comment. I don't know how serious it is if the assumption is violated.

I think if you have reverse-not-reachable blocks (infinite loops w/o
fake exit edges) that are not reachable from entry it will ICE
or loop infintely.

Richard.

> Thanks,
> - Tom
> 
> > Thanks,
> > Richard.
> > 
> > 2018-08-23  Richard Biener  <rguenther@suse.de>
> > 
> > 	* cfganal.h (verify_no_unreachable_blocks): Remove.
> > 	* cfganal.c (verify_no_unreachable_blocks): Likewise.
> > 	(inverted_post_order_compute): Do not call verify_no_unreachable_blocks
> > 	instead assert when we reach a block without predecessor that is not
> > 	the entry block.
> > 
> > diff --git a/gcc/cfganal.c b/gcc/cfganal.c
> > index 3b80758e8f2..baf9f0562f9 100644
> > --- a/gcc/cfganal.c
> > +++ b/gcc/cfganal.c
> > @@ -186,18 +186,6 @@ find_unreachable_blocks (void)
> >    free (worklist);
> >  }
> >  
> > -/* Verify that there are no unreachable blocks in the current function.  */
> > -
> > -void
> > -verify_no_unreachable_blocks (void)
> > -{
> > -  find_unreachable_blocks ();
> > -
> > -  basic_block bb;
> > -  FOR_EACH_BB_FN (bb, cfun)
> > -    gcc_assert ((bb->flags & BB_REACHABLE) != 0);
> > -}
> > -
> >  
> >  /* Functions to access an edge list with a vector representation.
> >     Enough data is kept such that given an index number, the
> > @@ -800,9 +788,6 @@ inverted_post_order_compute (vec<int> *post_order,
> >    basic_block bb;
> >    post_order->reserve_exact (n_basic_blocks_for_fn (cfun));
> >  
> > -  if (flag_checking)
> > -    verify_no_unreachable_blocks ();
> > -
> >    /* Allocate stack for back-tracking up CFG.  */
> >    auto_vec<edge_iterator, 20> stack (n_basic_blocks_for_fn (cfun) + 1);
> >  
> > @@ -866,7 +851,10 @@ inverted_post_order_compute (vec<int> *post_order,
> >                     time, check its predecessors.  */
> >  		stack.quick_push (ei_start (pred->preds));
> >                else
> > -		post_order->quick_push (pred->index);
> > +		{
> > +		  gcc_assert (pred->index == ENTRY_BLOCK);
> > +		  post_order->quick_push (pred->index);
> > +		}
> >              }
> >            else
> >              {
> > diff --git a/gcc/cfganal.h b/gcc/cfganal.h
> > index 122c665f7f6..ac3fe8f4617 100644
> > --- a/gcc/cfganal.h
> > +++ b/gcc/cfganal.h
> > @@ -50,7 +50,6 @@ private:
> >  
> >  extern bool mark_dfs_back_edges (void);
> >  extern void find_unreachable_blocks (void);
> > -extern void verify_no_unreachable_blocks (void);
> >  struct edge_list * create_edge_list (void);
> >  void free_edge_list (struct edge_list *);
> >  void print_edge_list (FILE *, struct edge_list *);
> > 
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]