Fix PR51572

Message ID alpine.LNX.2.00.1112161503060.4527@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 16, 2011, 2:06 p.m.
This fixes PR51572 - as with LTO we do not call debug_hooks->type_decl
for each global TYPE_DECL we run into the issue that if those are
emitted lazily they always end up in the limbo DIE list but are
later not allowed there (we ICE processing the limbo list).  The
fix is to not put those on the limbo list in the first place
if its context DIE will be a comp-unit-die which is similar enough
to the existing handling of NAMESPACE_DECL contexts.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Jason approved this on IRC so I will commit it once testing

[not changing the similar occurance a few lines below - I wasn't
able to create a testcase with a quick try, so I'll wait for one
to pop up in the wild]


2011-12-16  Richard Guenther  <>

	PR lto/51572
	* dwarf2out.c (gen_type_die_with_usage): Use the context of
	the TYPE_DECL as well if it is file-scope.

	* gcc.dg/lto/pr51572-1_0.c: New testcase.


Index: gcc/dwarf2out.c
--- gcc/dwarf2out.c	(revision 182398)
+++ gcc/dwarf2out.c	(working copy)
@@ -18842,8 +18849,9 @@  gen_type_die_with_usage (tree type, dw_d
       /* Use the DIE of the containing namespace as the parent DIE of
          the type description DIE we want to generate.  */
-      if (DECL_CONTEXT (TYPE_NAME (type))
+      if (DECL_FILE_SCOPE_P (TYPE_NAME (type))
+	  || (DECL_CONTEXT (TYPE_NAME (type))
 	context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
       TREE_ASM_WRITTEN (type) = 1;
Index: gcc/testsuite/gcc.dg/lto/pr51572-1_0.c
--- gcc/testsuite/gcc.dg/lto/pr51572-1_0.c	(revision 0)
+++ gcc/testsuite/gcc.dg/lto/pr51572-1_0.c	(revision 0)
@@ -0,0 +1,9 @@ 
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto -g } } } */
+typedef int T;
+void fn (void)
+  static T t;
+int main() {}