[PATCH] fix optimization/13024

Jeff Sturm jsturm@one-point.com
Sun Nov 23 16:12:00 GMT 2003


The PR includes a java test case that ICEes in make_edges due to a missing
JUMP_LABEL.

The rtl has an indirect jump resulting from expansion of a
TRY_FINALLY_EXPR.  At -O2, update_equiv_regs determines that the indirect
jump can become a direct jump, setting recorded_label_ref accordingly, so
that rest_of_compilation will rebuild_jump_labels.  (Interestingly,
-fnew-ra does not have this problem and never attempts to convert indirect
jumps.)

However that is too late for reloading, which needs a valid CFG with jump
labels intact if the function has abnormal edges.  I've found that calling
rebuild_jump_labels before global_alloc, rather than after, fixes the test
case and causes no regressions in any of the testsuites, including acats.

Tested on i686-pc-linux-gnu.  OK for 3.4?

Jeff

2003-11-23  Jeff Sturm  <jsturm@one-point.com>

	Fix PR optimization/13024.
	* toplev.c (rest_of_handle_new_regalloc): Remove rebuild_notes
	parameter.
	(rest_of_handle_old_regalloc): Likewise.  Add rebuild_notes
	declaration.  Rebuild jump labels following local_alloc if necessary.
	(rest_of_compilation): Remove rebuild_label_notes_after_reload
	declaration.  Don't pass rebuild_notes parameter to
	rest_of_handle_new_regalloc and rest_of_handle_old_regalloc.
	Don't rebuild jump labels.

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.844
diff -u -p -r1.844 toplev.c
--- toplev.c	13 Nov 2003 19:40:13 -0000	1.844
+++ toplev.c	22 Nov 2003 19:18:23 -0000
@@ -148,8 +148,8 @@ static void rest_of_handle_regmove (tree
 static void rest_of_handle_sched (tree, rtx);
 static void rest_of_handle_sched2 (tree, rtx);
 #endif
-static bool rest_of_handle_new_regalloc (tree, rtx, int *);
-static bool rest_of_handle_old_regalloc (tree, rtx, int *);
+static bool rest_of_handle_new_regalloc (tree, rtx);
+static bool rest_of_handle_old_regalloc (tree, rtx);
 static void rest_of_handle_regrename (tree, rtx);
 static void rest_of_handle_reorder_blocks (tree, rtx);
 #ifdef STACK_REGS
@@ -2188,7 +2188,7 @@ rest_of_handle_machine_reorg (tree decl,
 /* Run new register allocator.  Return TRUE if we must exit
    rest_of_compilation upon return.  */
 static bool
-rest_of_handle_new_regalloc (tree decl, rtx insns, int *rebuild_notes)
+rest_of_handle_new_regalloc (tree decl, rtx insns)
 {
   int failure;

@@ -2227,7 +2227,6 @@ rest_of_handle_new_regalloc (tree decl,
     return true;

   reload_completed = 1;
-  *rebuild_notes = 0;

   return false;
 }
@@ -2235,9 +2234,10 @@ rest_of_handle_new_regalloc (tree decl,
 /* Run old register allocator.  Return TRUE if we must exit
    rest_of_compilation upon return.  */
 static bool
-rest_of_handle_old_regalloc (tree decl, rtx insns, int *rebuild_notes)
+rest_of_handle_old_regalloc (tree decl, rtx insns)
 {
   int failure;
+  int rebuild_notes;

   /* Allocate the reg_renumber array.  */
   allocate_reg_info (max_regno, FALSE, TRUE);
@@ -2248,10 +2248,23 @@ rest_of_handle_old_regalloc (tree decl,
   allocate_initial_values (reg_equiv_memory_loc);

   regclass (insns, max_reg_num (), rtl_dump_file);
-  *rebuild_notes = local_alloc ();
+  rebuild_notes = local_alloc ();

   timevar_pop (TV_LOCAL_ALLOC);

+  /* Register allocation may have turned an indirect jump into a direct
+     jump.  If so, we must rebuild the JUMP_LABEL fields of jumping
+     instructions.  */
+  if (rebuild_notes)
+    {
+      timevar_push (TV_JUMP);
+
+      rebuild_jump_labels (insns);
+      purge_all_dead_edges (0);
+
+      timevar_pop (TV_JUMP);
+    }
+
   if (dump_file[DFI_lreg].enabled)
     {
       timevar_push (TV_DUMP);
@@ -3143,7 +3156,6 @@ void
 rest_of_compilation (tree decl)
 {
   rtx insns;
-  int rebuild_label_notes_after_reload;

   timevar_push (TV_REST_OF_COMPILATION);

@@ -3453,14 +3465,12 @@ rest_of_compilation (tree decl)

   if (flag_new_regalloc)
     {
-      if (rest_of_handle_new_regalloc (decl, insns,
-				       &rebuild_label_notes_after_reload))
+      if (rest_of_handle_new_regalloc (decl, insns))
 	goto exit_rest_of_compilation;
     }
   else
     {
-      if (rest_of_handle_old_regalloc (decl, insns,
-				       &rebuild_label_notes_after_reload))
+      if (rest_of_handle_old_regalloc (decl, insns))
 	goto exit_rest_of_compilation;
     }

@@ -3474,19 +3484,6 @@ rest_of_compilation (tree decl)
       timevar_push (TV_RELOAD_CSE_REGS);
       reload_cse_regs (insns);
       timevar_pop (TV_RELOAD_CSE_REGS);
-    }
-
-  /* Register allocation and reloading may have turned an indirect jump into
-     a direct jump.  If so, we must rebuild the JUMP_LABEL fields of
-     jumping instructions.  */
-  if (rebuild_label_notes_after_reload)
-    {
-      timevar_push (TV_JUMP);
-
-      rebuild_jump_labels (insns);
-      purge_all_dead_edges (0);
-
-      timevar_pop (TV_JUMP);
     }

   close_dump_file (DFI_postreload, print_rtl_with_bb, insns);



More information about the Gcc-patches mailing list