Fixing jumps reachability after block reordering

Ian Lance Taylor iant@google.com
Fri Jul 6 17:33:00 GMT 2007


"Gregory B. Prokopski" <gadek@debian.org> writes:

> +++ Ian Lance Taylor [06/07/07 09:16 -0700]:
> > shorten_branches should work correctly--you shouldn't need to do
> > anything special.  My only guess is that there is something wrong with
> > the way you are reordering the blocks.  For example, perhaps you are
> > simply reordering the CFG without reordering the insn chain.  Note
> > that shorten_branches is not (yet) CFG aware.  It simply walks the
> > insn chain.
> 
> To reorder BBs I use the following procedure:
> 
> 1. cfg_layout_initialize (0);
> 2. FOR_EACH_BB(bb) set bb->rbi->next properly for each, so they all create
>   a chain of BB
> 3. cfg_layout_finalize();
> 
> Does this reorder the insn chain?  If not, how do I reorder it? 
> Or where do I look for how it's done?

I think that should work.  Although it's bb->aux, not bb->rbi->next.
I'm not sure what bb->rbi is; which version of gcc are you using?

The code to get the insn chain correct is fixup_reorder_chain in
cfglayout.c.

Ian



More information about the Gcc mailing list