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]

fix -fcompare-debug regression DCEing debug stmts


If DCE manages to remove only debug stmts in a run, a compile run
without debug stmts wouldn't have removed anything, and compilation
might diverge.

This is not just theoretical.  build/error.c on ia64-linux-gnu fails
-fcompare-debug in just this way: cddce2 compiling trim_filename()
removes nothing in the -g0 compilation, whereas the -g compilation
removes debug stmts, so that something_changed ends up returned up as a
number of cleanup passes.

Even in the -g0 compilation, these cleanup passes would eventually run
after another pass, and the executable at the end happens to be, by
chance, exactly the same as if the cleanups had run early.  However,
-fcompare-debug detects and reports the differences in numbers assigned
to pseudos and basic blocks, which indicates at least a strong potential
for errors in codegen differences.

This patch arranges for something_changed to not be set upon removal of
a debug stmt, so that no cleanups are run in -g compilation that
wouldn't have run with -g0.

This problem was introduced recently, in the patch that enabled debug
temps bind stmts to be cleaned up.  Earlier, DCE would never remove
debug stmts, so the problem did not occur.

This patch has completed the stage3 of a bootstrap-debug-lean bootstrap
on ia64-linux-gnu, and it's now almost done building target libraries.
Unfortunately, I won't be able to wait for the regression testing to
complete before I leave for a 1-week trip with unknown Internet access
expectations.  If this is approved, would someone (Jakub?) please go
ahead and check it in?

Thanks in advance,

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Don't regard
	the removal of a debug stmt as a significant change.

Index: gcc/tree-ssa-dce.c
===================================================================
--- gcc/tree-ssa-dce.c.orig	2009-10-19 12:29:56.000000000 -0200
+++ gcc/tree-ssa-dce.c	2009-10-19 12:30:36.000000000 -0200
@@ -1129,8 +1129,9 @@ eliminate_unnecessary_stmts (void)
 	  /* If GSI is not necessary then remove it.  */
 	  if (!gimple_plf (stmt, STMT_NECESSARY))
 	    {
+	      if (!is_gimple_debug (stmt))
+		something_changed = true;
 	      remove_dead_stmt (&gsi, bb);
-	      something_changed = true;
 	    }
 	  else if (is_gimple_call (stmt))
 	    {
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

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