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]

[vta] tree-ssa-dce debug-stmt stability, block deletion order


This patch fixes two problems in tree-ssa-dce.c

One is a compare-debug problem, caused by marking blocks as containing
live stmts.  Debug stmts are always marked as necessary, but blocks that
don't contain any non-debug necessary stmt can be deleted.  Marking
blocks because of debug stmts causes compare-debug failures.

The other is the same problem as in the previous patch, of removal of
DEFs before USEs in debug insns.  Walking blocks backwards fixes it.

I'm installing this in the VTA branch.  VTA4.4 doesn't track blocks
containing live stmts, and it doesn't delete blocks like VTA, so it
doesn't need this patch.

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

	* tree-ssa-dce.c (mark_stmt_necessary): Don't mark block as
	containing live stmts because of debug insn.
	(eliminate_unnecessary_stmts): Walk blocks backwards.

Index: gcc/tree-ssa-dce.c
===================================================================
--- gcc/tree-ssa-dce.c.orig	2009-07-29 23:47:10.000000000 -0300
+++ gcc/tree-ssa-dce.c	2009-08-06 08:43:40.000000000 -0300
@@ -221,7 +221,7 @@ mark_stmt_necessary (gimple stmt, bool a
   gimple_set_plf (stmt, STMT_NECESSARY, true);
   if (add_to_worklist)
     VEC_safe_push (gimple, heap, worklist, stmt);
-  if (bb_contains_live_stmts)
+  if (bb_contains_live_stmts && !is_gimple_debug (stmt))
     SET_BIT (bb_contains_live_stmts, gimple_bb (stmt)->index);
 }
 
@@ -1161,11 +1161,11 @@ eliminate_unnecessary_stmts (void)
      Mark them for renaming.  */
   if (cfg_altered)
     {
-      basic_block next_bb;
+      basic_block prev_bb;
       find_unreachable_blocks ();
-      for (bb = ENTRY_BLOCK_PTR->next_bb; bb != EXIT_BLOCK_PTR; bb = next_bb)
+      for (bb = EXIT_BLOCK_PTR->prev_bb; bb != ENTRY_BLOCK_PTR; bb = prev_bb)
 	{
-	  next_bb = bb->next_bb;
+	  prev_bb = bb->prev_bb;
 	  if (!TEST_BIT (bb_contains_live_stmts, bb->index)
 	      || !(bb->flags & BB_REACHABLE))
 	    {
-- 
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]