re PR lto/45089 (-Os -g -fwhopr dwarf2out ICE)
authorRichard Guenther <rguenther@suse.de>
Thu, 18 Nov 2010 14:11:00 +0000 (14:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 18 Nov 2010 14:11:00 +0000 (14:11 +0000)
2010-11-18  Richard Guenther  <rguenther@suse.de>

PR lto/45089
* dwarf2out.c (add_AT_die_ref): Work around LTO losing types
when checking is not enabled.

From-SVN: r166904

gcc/ChangeLog
gcc/dwarf2out.c

index 3e589d2ac3cc6b9470ccbdc2c314166b090ba6a1..9490dd36ebe9f9ff1054d9e411ad6599f2bd160a 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-18  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/45089
+       * dwarf2out.c (add_AT_die_ref): Work around LTO losing types
+       when checking is not enabled.
+
 2010-11-18  Richard Guenther  <rguenther@suse.de>
 
        PR lto/46525
index 4eade28815a49e009ab322aeef7271da4c2a89ad..ea3852e172f4017f922eb9c0a39448a277f59f10 100644 (file)
@@ -7362,6 +7362,15 @@ add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_
 {
   dw_attr_node attr;
 
+#ifdef ENABLE_CHECKING
+  gcc_assert (targ_die != NULL);
+#else
+  /* With LTO we can end up trying to reference something we didn't create
+     a DIE for.  Avoid crashing later on a NULL referenced DIE.  */
+  if (targ_die == NULL)
+    return;
+#endif
+
   attr.dw_attr = attr_kind;
   attr.dw_attr_val.val_class = dw_val_class_die_ref;
   attr.dw_attr_val.v.val_die_ref.die = targ_die;