http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54632



Richard Guenther <rguenth at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|UNCONFIRMED                 |ASSIGNED

   Last reconfirmed|                            |2012-09-24

         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org

                   |gnu.org                     |

     Ever Confirmed|0                           |1



--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-24 
12:42:27 UTC ---

The backtrace hints at trees containing DECL_VALUE/DEBUG_EXPRs.  We

are indeed writing TREE_BLOCK which has been garbage-collected.



(gdb) up

#3  0x0000000000dcf803 in write_ts_exp_tree_pointers (ob=0x1c809d0, 

    expr=0x7ffff4de0000, ref_p=true)

    at /space/rguenther/src/svn/trunk/gcc/tree-streamer-out.c:674

674       stream_write_tree (ob, TREE_BLOCK (expr), ref_p);

...

#7  0x0000000000dcea3c in write_ts_decl_common_tree_pointers (ob=0x1c809d0, 

    expr=0x7ffff4ddc2f8, ref_p=true)

    at /space/rguenther/src/svn/trunk/gcc/tree-streamer-out.c:509

509         stream_write_tree (ob, DECL_DEBUG_EXPR (expr), ref_p);

...

#11 0x0000000000ad8e10 in output_struct_function_base (ob=0x1c809d0, 

    fn=0x7ffff5440c80)

    at /space/rguenther/src/svn/trunk/gcc/lto-streamer-out.c:751

748       /* Output all the local variables in the function.  */

749       streamer_write_hwi (ob, VEC_length (tree, fn->local_decls));

750       FOR_EACH_VEC_ELT (tree, fn->local_decls, i, t)

751         stream_write_tree (ob, t, true);



so somehow GC does not mark this block as used (or it is not marked

as used in the block tree and thus removed in remove_unused_scope_block_p).



We indeed forget to walk all locals in clear_unused_block_pointer ().



Testing



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_VEC_ELT (tree, cfun->local_decls, 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))

       {

Reply via email to