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,RFC]: Change entry block and exit block to non-negativenumbers


On Wed, 2005-04-20 at 22:22, Daniel Berlin wrote:
> On Wed, 2005-04-20 at 15:28 -0400, Diego Novillo wrote:
> > On Thu, Apr 07, 2005 at 04:19:02PM -0400, Daniel Berlin wrote:
> > 
> > > We have a significant amount of code that checks for entry block or exit
> > > block because BASIC_BLOCK_INFO doesn't work on them, or adds two (or
> > > subtracts INVALID_BLOCK + 1) in random places to try to avoid the
> > > negative numbers, or doesn't directly index into an array by bb->index
> > > to avoid adding two, etc.
> > > 
> > I don't mind either way.  Negative numbers in ENTRY/EXIT is
> > annoying at times, but not significantly. 
> 
> I'm not sure i agree it's not significantly annoying, but only because
> i've looked at a lot of the code that does it

<...>

> 
> Note the *only* reason it checks for EXIT_BLOCK_PTR is to avoid having a
> negative index into the array.
> 
> This stuff really runs wild in our code.
> 
> Besides making our code ugly, its hacking around things like this that
> cause us to get properties of EXIT_BLOCK and ENTRY_BLOCK wrong, too (See
> bug 17951 for an example).

I suspect the reason ENTRY and EXIT are negative was probably laziness
to avoid going through the code and finding which of the places that
loop from index 0 to n_basic_blocks would break if ENTRY and EXIT were
included. As well as many historical places which probably assumed block
0 was the entry block.

A lot has changed since those days.

Any of these which still exist ought to be eliminated, and I see no
earthly reason why we shouldn't go ahead with this.

Andrew


The only observation I have is that perhaps we could also provide
FIRST_BLOCK (or some better name) as a duplicate of NUM_FIXED_BLOCKS
since the loops seem to read clearer if it says
   for (i = FIRST_BLOCK; i < n_basic_blocks; i++)
instead of
   for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++) 

(I have to think about the latter for a few extra milliseconds... and we
all know how much I hate to think :-)

but thats a pretty minor thing and purely personal preference. :-)



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