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]

[lto] fix debug information for global initialized variables


When the LTO reader read in DIEs for global variables, it expected that
DW_AT_declaration would be unset if an initializer of some sort needed
to be read in as well.  However, due to the way force_decl_die works, we
would always set DW_AT_declaration on global variables.  The result was
that the LTO reader wouldn't read in initializers and we would wind up
failing testcases like 20000227-1.c because the generated assembly would
contain references to 'f' and 'g'.

Fixed with the following patch.  Applied to the LTO branch.

-Nathan

2007-11-09  Nathan Froyd  <froydnj@codesourcery.com>

	* dwarf2out.c (lto_var_ref): Remove DW_AT_declaration if we are
	forcing an initialized global variable.

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 129966)
+++ gcc/dwarf2out.c	(working copy)
@@ -15137,6 +15137,11 @@ lto_var_ref (tree var,
   gcc_assert (TREE_CODE (var) == VAR_DECL);
   /* Generate the DIE for VAR.  */
   die = force_decl_die (var);
+  /* If we are forcing an initialized global variable, then remove
+     DW_AT_declaration so the LTO reader understands that we need to
+     read in its initializer.  */
+  if (DECL_CONTEXT (var) == NULL_TREE && DECL_INITIAL (var))
+    remove_AT (die, DW_AT_declaration);
   /* Construct the reference.  */
   lto_init_ref (ref, die, DECL_CONTEXT (var));
 }


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