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]

[dataflow, committed] fix pr/31025


This is a fix for a bug in dataflow analysis that occurs when
you have an interesting combination of may-uninitialized
variables and function calls.  The bug is detected by an
assertion check in caller-save.c.

caller_save uses REG_N_CALLS_CROSSED it to decide what to save
(in advance), and urec to decide whether to save something (while
scanning the insns).  But REG_N_CALLS_CROSSED is always computed
using live, not urec.  

And since reg 58 is not in live but it is in urec, caller_save
thinks that reg 58 doesn't have to be saved (using live) and yet
it tries to save it (using urec).

The fix is to use urec to compute reg_info data whenever it is
available.  This gives worse info in general (urec is completely
brain-damaged) but consistent info.

I committed it after regtesting on i686-pc-linux-gnu twice
(on dataflow-branch "as is", and without Steven's DCE patch).

Paolo


2007-03-16  Paolo Bonzini  <bonzini@gnu.org>

        PR rtl-optimization/31025
        * gfortran.dg/pr31025.f90: New.


real*8 function f(x)
t1 = g(0)
if(x .eq. 0) then
  f = 0
else if(x .eq. 1) then
  f = t1 *log( t1 )
end if
end
2007-03-15  Paolo Bonzini  <bonzini@gnu.org>

	* df.h (df_get_live_out): Declare.
	* df-problems.c (df_get_live_out): New.
	(df_ri_bb_compute): Use it.

Index: df.h
===================================================================
--- df.h	(revision 122655)
+++ df.h	(working copy)
@@ -882,6 +882,7 @@ extern struct df_link *df_chain_create (
 extern void df_chain_unlink (struct df_ref *);
 extern void df_chain_copy (struct df_ref *, struct df_link *);
 extern bitmap df_get_live_in (basic_block);
+extern bitmap df_get_live_out (basic_block);
 extern bitmap df_get_live_top (basic_block);
 extern void df_grow_bb_info (struct dataflow *);
 extern void df_chain_dump (struct df_link *, FILE *);
Index: df-problems.c
===================================================================
--- df-problems.c	(revision 122655)
+++ df-problems.c	(working copy)
@@ -59,6 +59,22 @@ static bitmap seen_in_insn = NULL;
 /*----------------------------------------------------------------------------
    Public functions access functions for the dataflow problems.
 ----------------------------------------------------------------------------*/
+/* Get the live at out set for BB no matter what problem happens to be
+   defined.  This function is used by the register allocators who
+   choose different dataflow problems depending on the optimization
+   level.  */
+
+bitmap
+df_get_live_out (basic_block bb)
+{
+  gcc_assert (df_lr);
+
+  if (df_urec)
+    return DF_RA_LIVE_OUT (bb);
+  else 
+    return DF_LIVE_OUT (bb);
+}
+
 /* Get the live at in set for BB no matter what problem happens to be
    defined.  This function is used by the register allocators who
    choose different dataflow problems depending on the optimization
@@ -4303,7 +4319,7 @@ df_ri_bb_compute (unsigned int bb_index,
   struct df_ref **use_rec;
   int luid = 0;
 
-  bitmap_copy (live, DF_LIVE_OUT (bb));
+  bitmap_copy (live, df_get_live_out (bb));
   bitmap_clear (artificial_uses);
 
 #ifdef REG_DEAD_DEBUGGING

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