Patchwork Fix PR54632

login
register
mail settings
Submitter Richard Guenther
Date Sept. 24, 2012, 12:46 p.m.
Message ID <alpine.LNX.2.00.1209241444480.4063@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/186394/
State New
Headers show

Comments

Richard Guenther - Sept. 24, 2012, 12:46 p.m.
This fixes PR54632 - we can end up with garbage collected BLOCKs
(those not part of any BLOCK tree) being still referenced from
DECL_DEBUG_EXPRs.  We try to handle that in clear_unused_block_pointer
but fail to walk all local decls as source of them (but only catch
those that are still actively used in stmt operands).

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-09-24  Richard Guenther  <rguenther@suse.de>

	PR middle-end/54632
	* tree-ssa-live.c (clear_unused_block_pointer_1): Do not
	handle DECL_DEBUG_EXPR_IS_FROM here...
	(clear_unused_block_pointer): ... but here when walking all
	local decls.

Patch

Index: gcc/tree-ssa-live.c
===================================================================
--- gcc/tree-ssa-live.c	(revision 191664)
+++ gcc/tree-ssa-live.c	(working copy)
@@ -620,11 +620,6 @@  clear_unused_block_pointer_1 (tree *tp,
   if (EXPR_P (*tp) && TREE_BLOCK (*tp)
       && !TREE_USED (TREE_BLOCK (*tp)))
     TREE_SET_BLOCK (*tp, NULL);
-  if (TREE_CODE (*tp) == VAR_DECL && DECL_DEBUG_EXPR_IS_FROM (*tp))
-    {
-      tree debug_expr = DECL_DEBUG_EXPR (*tp);
-      walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
-    }
   return NULL_TREE;
 }
 
@@ -636,6 +631,16 @@  clear_unused_block_pointer ()
 {
   basic_block bb;
   gimple_stmt_iterator gsi;
+  tree t;
+  unsigned i;
+
+  FOR_EACH_LOCAL_DECL (cfun, i, t)
+    if (TREE_CODE (t) == VAR_DECL && DECL_DEBUG_EXPR_IS_FROM (t))
+      {
+	tree debug_expr = DECL_DEBUG_EXPR (t);
+	walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
+      }
+
   FOR_EACH_BB (bb)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {