This is the mail archive of the 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]

[PATCH] EH_USES df fix (PR target/37378)


Up to 4.1 flow.c used EH_USES in 2 places, to mark registers used on EH
edges and registers used after by bb's without successors (that means
usually noreturn calls).  While the epilogue explicitly uses all EH_USES
registers (it restores various special registers from the values saved in
EH_USES registers and the special registers are said to be live at the end
of epilogue), with noreturn calls the epilogue isn't reached, yet we still
need EH_USES registers to be live from the insn which saved special register
into a particular EH_USES register until the last insn in the function
(in this case the noreturn call).  We need them for 2 reasons:
1) for every insn that might throw externally (i.e. not be caught within
   the same function, but parent etc.), the EH_USES registers are used
   by the unwinder
2) for debugging purposes, we need those registers to be live at every
   single insn within the function once the special register has been
While for 1) we could add explicit artificial uses to every such potentially
throwing insn, for 2) it would be a very bad idea.  And even for 1) it would
be IMHO an overkill, as the insns in prologue that save special regs into
EH_USES registers are all RTX_FRAME_RELATED_P and thus can't be simply
removed as unneeded.  So it is IMHO enough to say EH_USES registers
are used by top of BBs with incoming EH edges (this has been already done in
df) and by noreturn calls.  Otherwise we risk that the saving insn in the
prologue is moved beyond a branch to bb's ending with noreturn call, as
can be seen in miscompiled _Jv_divI (see PR).

The other hunk just removes an unnecessary nop - EH_USES is only defined
(to non-0) on ia64 and only if reload_completed, but it has been used
inside of if (!reload_completed), so it actually never could make any

Bootstrapped/regtested on ia64-linux, libjava make check now looks
much better than before:
FAIL: getlocalvartable output
FAIL: Throw_3 -O3 output - source compiled test
FAIL: Throw_3 -O3 -findirect-dispatch output - source compiled test

Ok for trunk?

2008-10-27  Jakub Jelinek  <>

	PR target/37378
	* df-scan.c (df_get_call_refs): For unconditional noreturn
	calls add EH_USES regs as artificial uses.
	(df_get_entry_block_def_set): Don't handle EH_USES here.

--- gcc/df-scan.c.jj	2008-10-14 07:58:50.000000000 -0400
+++ gcc/df-scan.c	2008-10-27 07:26:20.000000000 -0400
@@ -3406,7 +3406,22 @@ df_get_call_refs (struct df_collection_r
   BITMAP_FREE (defs_generated);
-  return;
+#ifdef EH_USES
+  if ((flags & DF_REF_CONDITIONAL) == 0
+      && find_reg_note (insn_info->insn, REG_NORETURN, 0))
+    {
+      unsigned int i;
+      /* This code is putting in an artificial ref for the use at the
+	 BOTTOM of the block with noreturn call, as EH_USES registers need
+	 to be live until epilogue or noreturn call, for debugging purposes
+	 as well as any insns that might throw.  */
+      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+	if (EH_USES (i))
+	  df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i],
+			 NULL, bb, NULL, DF_REF_REG_USE, 0, -1, -1, 0);
+    }
 /* Collect all refs in the INSN. This function is free of any
@@ -3826,16 +3841,6 @@ df_get_entry_block_def_set (bitmap entry
   /* These registers are live everywhere.  */
   if (!reload_completed)
-#ifdef EH_USES
-      /* The ia-64, the only machine that uses this, does not define these 
-	 until after reload.  */
-      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-	if (EH_USES (i))
-	  {
-	    bitmap_set_bit (entry_block_defs, i);
-	  }
       /* Pseudos with argument area equivalences may require
 	 reloading via the argument pointer.  */


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