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: [tree-ssa] Fix make_goto_expr_edges for computed gotos


On Wed, 2003-08-20 at 14:22, Zdenek Dvorak wrote:

> > > make_goto_expr_edges tests just the first label in a block for possibility of
> > > being a target of computed/nonlocal goto, which is wrong.
> > > 
> > Do you have a test case?
> 
> here it is:
> 
Thanks.  Please commit this test case.  As far as the patch goes, this
is what I had in mind when I suggested adjusting stmt_starts_bb_p:

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.153
diff -d -u -p -r1.1.4.153 tree-cfg.c
--- tree-cfg.c  20 Aug 2003 19:03:48 -0000      1.1.4.153
+++ tree-cfg.c  20 Aug 2003 23:53:19 -0000
@@ -3261,6 +3261,12 @@ stmt_starts_bb_p (tree t, tree prev_t)
   code = TREE_CODE (t);
   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
     {
+      /* Nonlocal and computed GOTO targets always start a new block.  */
+      if (code == LABEL_EXPR
+         && (NONLOCAL_LABEL (LABEL_EXPR_LABEL (t))
+             || FORCED_LABEL (LABEL_EXPR_LABEL (t))))
+       return true;
+
       if (prev_t && TREE_CODE (prev_t) == code)
        {
          if (code == LABEL_EXPR)

It fixes the test case and prevents the scanning of all the labels in
each basic block (which, admittedly shouldn't be too expensive, but
we're about to become extremely label happy).

I'll commit the patch after bootstrapping/testing it.


Diego.


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