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]

PR middle-end/20606: 4.0 regression: ICE in make_edges, at cfgbuild.c:327


This is 4.0 branch ONLY.  Mainline is OK.

This happens because we see a Java exception handler that looks like
this:

                catch ((void *) &_Utf6_ref)
                   {
                     goto *.LJpc=119;
                   }
               }
           }
           *.LJpc=119:;

gcc decides as the catch block is empty aprt from the goto, this is a
fallthrough and attempts to merge the basic blocks, whereupon it falls
down in a heap.  This only happens with Java, because C++ always has
some code other than a goto in the catch block.

This patch is a workaround rather than a fix, but on the plus side
it's non-intrusive and doesn't affect other langauges at all -- I'm
simply going to put an asm("") in the catch block before the goto.

Andrew.



2005-07-14  Andrew Haley  <aph@redhat.com>

	* except.c (expand_end_java_handler): Insert an empty ASM_EXPR at
	the start of each catch block.
	
Index: java/except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/except.c,v
retrieving revision 1.47.10.1
diff -c -2 -p -r1.47.10.1 except.c
*** java/except.c	28 Apr 2005 16:35:22 -0000	1.47.10.1
--- java/except.c	14 Jul 2005 14:34:30 -0000
*************** expand_end_java_handler (struct eh_range
*** 497,505 ****
  
        {
! 	tree catch_expr = build2 (CATCH_EXPR, void_type_node, type,
! 				  build1 (GOTO_EXPR, void_type_node,
! 					  TREE_VALUE (handler)));
! 	tree try_catch_expr = build2 (TRY_CATCH_EXPR, void_type_node,
! 				      *get_stmts (), catch_expr);	
  	*get_stmts () = try_catch_expr;
        }
--- 497,515 ----
  
        {
! 	tree goto_expr = build1 (GOTO_EXPR, void_type_node,
! 				 TREE_VALUE (handler));
! 	/* Build an asm to prevent gcc from attempting to merge this
! 	   handler with the next basic block; this is a workaround for
! 	   a bug in cfgbuild.c.  */
! 	tree asm_expr = build (ASM_EXPR, void_type_node,
! 			       build_string (0, ""),
! 			       NULL_TREE, NULL_TREE, NULL_TREE);
! 	tree compound = build2 (COMPOUND_EXPR, void_type_node,
! 				asm_expr, goto_expr);
! 	tree try_catch_expr 
! 	  = build2 (TRY_CATCH_EXPR, void_type_node,
! 		    *get_stmts (), 
! 		    build2 (CATCH_EXPR, void_type_node, type, 
! 			    compound));
  	*get_stmts () = try_catch_expr;
        }


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