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 rationale question


The below patch fixes a couple of issues:

- When we moved to generating early debug information for LTO, we
  created a problem where, essentially, every function was considered an
  abstract instance of itself.  Every function was considered as being
  possibly inlined, as cgraph had not yet worked its magic on the call
  graph.  However, in dwarf2out_abstract_function, we'd do this:

  set_decl_abstract_flags (decl, 1);
  dwarf2out_decl (decl);
  if (! was_abstract)
    set_decl_abstract_flags (decl, 0);

  which, since our original decl was not abstract, would merrily sweep
  through the function turning all the local variables
  non-abstract--including things like __FUNCTION__.  The net result is
  that the DWARF entries for __FUNCTION__ wound up with only a location
  and no name or type information, which caused problems in the reader.

  The patch fixes things by checking whether cgraph has analyzed things
  in sufficient detail before declaring that a function is potentially
  inlined.

- lto_read_DIE_at_ptr should not be doing checking for a null result.
  That responsibility is reserved for its callers, who can then decide
  whether a null result is cause for concern.  This fixes cases where
  we'd attempt to read a variable DIE, follow an DW_AT_abstract_origin
  reference, attempt to read the referenced DIE via lto_read_DIE_at_ptr,
  and then fall over because we didn't read anything--it would have been
  perfectly valid to return NULL from the first variable read, and this
  is what we do now.

- We would sometimes dereference a NULL pointer when reading a
  DW_TAG_variable DIE.  Oops.

I also took this opportunity to move a ChangeLog entry I accidentally
placed in gcc/ChangeLog to gcc/ChangeLog.lto.

Committed to the LTO branch.

-Nathan

2007-10-19  Nathan Froyd  <froydnj@codesourcery.com>

	* dwarf2out.c (gen_decl_die): Check cgraph_global_info_ready to determine
	whether we can output information for abstract instances.

2007-10-19  Nathan Froyd  <froydnj@codesourcery.com>

	* lto.c (lto_read_variable_formal_parameter_constant_DIE): Check
	whether SPECIFICATION or ABSTRACT_ORIGIN exist before inspecting
	fields within.
	(lto_read_DIE_at_ptr): Delete check for null result; let callers
	handle this appropriately.

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 129458)
+++ dwarf2out.c	(working copy)
@@ -13692,8 +13692,12 @@ gen_decl_die (tree decl, dw_die_ref cont
 	dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl));
 
       /* If we're emitting an out-of-line copy of an inline function,
-	 emit info for the abstract instance and set up to refer to it.  */
-      else if (cgraph_function_possibly_inlined_p (decl)
+	 emit info for the abstract instance and set up to refer to it.
+
+         We check cgraph_global_info_ready as a way of determining
+         whether we are generating debug information for LTO.  */
+      else if (cgraph_global_info_ready
+	       && cgraph_function_possibly_inlined_p (decl)
 	       && ! DECL_ABSTRACT (decl)
 	       && ! class_or_namespace_scope_p (context_die)
 	       /* dwarf2out_abstract_function won't emit a die if this is just
Index: lto.c
===================================================================
--- lto.c	(revision 129495)
+++ lto.c	(working copy)
@@ -2081,10 +2081,10 @@ lto_read_variable_formal_parameter_const
   else
     {
       /* Check for a referenced declaration.  */
-      if ((specification || abstract_origin)
-	  && !name
-	  && !type
-	  && TREE_CODE (specification) == code)
+      if (!name
+          && !type
+          && ((specification && TREE_CODE (specification) == code)
+              || (abstract_origin && TREE_CODE (abstract_origin) == code)))
         {
           /* Make sure we have one or the other.  */
           gcc_assert (!specification || !abstract_origin);
@@ -3424,9 +3424,6 @@ lto_read_DIE_at_ptr (lto_info_fd *info_f
       fd->cur = (const char *) ptr;
       result = lto_read_DIE (info_fd, context, NULL);
 
-      if (!result)
-        lto_file_corrupt_error (fd);
-
       fd->cur = saved_die;
     }
   return result;


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