This is the mail archive of the 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]

Re: Put scope blocks on a diet

On Oct 10, 2007, Jan Hubicka <> wrote:

>> I did this, but then I wonder...  How come the differences in decl
>> uids arise from inlining of removed variables, if the patch was
>> supposed to take effect only after inlining?

> cfun->after_inline is set after fixup_cfg [...]
> On mainline fixup_cfg is executed after apply_inline


>> If it is, then the test is meaningless.  The problem arises when we
>> change the declarations in a function's logical blocks and then inline
>> into others.

>> What am I missing?

That remove_unused_locals() was called by other post-pass TODOs, and
that it would remove blocks that didn't contain any sub-blocks but
that did contain declarations.  This caused variables only referenced
in debug stmts to be wiped away too early.

This alternate patch arranges for such blocks to not be deleted before
inlining.  I'm not entirely sure removing them too early might
possibly result in changes to the generated code, but I can't think of
a case in which it would, with the current (trunk) debug info


Here's the patch I'm testing now.

for gcc/ChangeLog
from  Alexandre Oliva  <>, Jan Hubicka  <>

	* tree-ssa-live.c (remove_unused_scope_block_p): Drop
	declarations and blocks only after inlining.  Check that
	non-empty blocks are not dropped.
	* tree-inline.c (expand_call_inline): Check that functions are
	not inlined too late.

Index: gcc/tree-ssa-live.c
--- gcc/tree-ssa-live.c.orig	2007-10-07 19:57:10.000000000 -0300
+++ gcc/tree-ssa-live.c	2007-10-11 02:47:17.000000000 -0300
@@ -493,8 +493,15 @@ remove_unused_scope_block_p (tree scope)
       /* When we are not doing full debug info, we however can keep around
 	 only the used variables for cfgexpand's memory packing saving quite
 	 a lot of memory.  */
-      else if (debug_info_level != DINFO_LEVEL_NORMAL
-	       && debug_info_level != DINFO_LEVEL_VERBOSE)
+      else if (debug_info_level == DINFO_LEVEL_NORMAL
+	       || debug_info_level == DINFO_LEVEL_VERBOSE
+	       /* Removing declarations before inlining is going to affect
+		  DECL_UID that in turn is going to affect hashtables and
+		  code generation.  */
+	       || !cfun->after_inlining)
+	unused = false;
+      else
 	  *t = TREE_CHAIN (*t);
 	  next = t;
@@ -516,7 +523,10 @@ remove_unused_scope_block_p (tree scope)
 	    nsubblocks ++;
-          *t = BLOCK_CHAIN (*t);
+	  {
+	    gcc_assert (!BLOCK_VARS (*t));
+	    *t = BLOCK_CHAIN (*t);
+	  }
Index: gcc/tree-inline.c
--- gcc/tree-inline.c.orig	2007-10-11 02:44:04.000000000 -0300
+++ gcc/tree-inline.c	2007-10-11 02:49:00.000000000 -0300
@@ -2640,6 +2640,8 @@ expand_call_inline (basic_block bb, tree
   id->src_cfun = DECL_STRUCT_FUNCTION (fn);
   id->call_expr = t;
+  gcc_assert (!id->src_cfun->after_inlining);
   initialize_inlined_parameters (id, t, fn, bb);
   if (DECL_INITIAL (fn))

Alexandre Oliva
FSF Latin America Board Member
Red Hat Compiler Engineer   aoliva@{,}
Free Software Evangelist  oliva@{,}

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