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 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

Count how many places have crap like:

flow.c:  queue = xmalloc ((n_basic_blocks - (INVALID_BLOCK + 1)) *
sizeof (*queue));
flow.c:  qhead = qend = queue + n_basic_blocks - (INVALID_BLOCK + 1);
flow.c:      if (local_sets[bb->index - (INVALID_BLOCK + 1)] == NULL)
flow.c:   local_sets[bb->index - (INVALID_BLOCK + 1)]

or 
cfganal.c:#define MARK_VISITED(BB) (SET_BIT (visited, (BB)->index + 2))
cfganal.c:#define UNMARK_VISITED(BB) (RESET_BIT (visited, (BB)->index +
2))
cfganal.c:  MARK_VISITED (bb);
cfganal.c:              MARK_VISITED (e->src);
cfganal.c:              MARK_VISITED (e->dest);
cfganal.c:    UNMARK_VISITED (rslt[sp]);
cfganal.c:#undef MARK_VISITED
cfganal.c:#undef UNMARK_VISITED
tree-ssa-phiopt.c:#define MARK_VISITED(BB) (SET_BIT (visited,
(BB)->index + 2))
tree-ssa-phiopt.c:  MARK_VISITED (ENTRY_BLOCK_PTR);
tree-ssa-phiopt.c:        MARK_VISITED (y);
tree-ssa-phiopt.c:      MARK_VISITED (y);
tree-ssa-phiopt.c:#undef MARK_VISITED

(hey, look, we even copy and pasted the exact same hack into a new
file!)

or, from sbitmap.c:

  for (e = NULL, ix = 0; ix < EDGE_COUNT (b->succs); ix++)
    {
      e = EDGE_SUCC (b, ix);
      if (e->dest == EXIT_BLOCK_PTR)
        continue;

      sbitmap_copy (dst, src[e->dest->index]);
      break;
    }

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).


>  If there is no strong
> opposition to this change, I wouldn't mind it.

Yay, that's the kind of support i'm looking for!

:)
Seriously though, i'll submit a new patch on the 25th
> 
> 
> Diego.


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