re PR debug/86585 (ICE in gen_member_die, at dwarf2out.c:24935)
authorRichard Biener <rguenther@suse.de>
Fri, 20 Jul 2018 11:13:47 +0000 (11:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Jul 2018 11:13:47 +0000 (11:13 +0000)
2018-07-20  Richard Biener  <rguenther@suse.de>

PR debug/86585
* dwarf2out.c (dwarf2out_die_ref_for_decl): Test in_lto_p
to cover -flto-partition=none.

lto/
* lto.c (unify_scc): Before we throw away an SCC see if we
can amend prevailing single-entry SCC with debug refs.

* g++.dg/lto/pr86585_0.C: New testcase.
* g++.dg/lto/pr86585_1.C: Likewise.

From-SVN: r262901

gcc/ChangeLog
gcc/dwarf2out.c
gcc/lto/ChangeLog
gcc/lto/lto.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr86585_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr86585_1.C [new file with mode: 0644]

index eed62bd865d7e806d62aaad7f5673635d2fa5334..b21ded86fb4954a21e8d9324e817d1219fc3ffe4 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-20  Richard Biener  <rguenther@suse.de>
+
+       PR debug/86585
+       * dwarf2out.c (dwarf2out_die_ref_for_decl): Test in_lto_p
+       to cover -flto-partition=none.
+
 2018-07-20  Martin Liska  <mliska@suse.cz>
 
        * tree.h (DECL_LOCATION_RANGE): Remove unused macro.
index bd45e0b06850dac46ec08f12999deb8cdb7e9321..8377cbc5dd1a97cf6a6759d5b52d29b49011845f 100644 (file)
@@ -5851,8 +5851,7 @@ dwarf2out_die_ref_for_decl (tree decl, const char **sym,
 {
   dw_die_ref die;
 
-  if ((flag_wpa || flag_incremental_link == INCREMENTAL_LINK_LTO)
-      && !decl_die_table)
+  if (in_lto_p && !decl_die_table)
     return false;
 
   if (TREE_CODE (decl) == BLOCK)
@@ -5865,8 +5864,7 @@ dwarf2out_die_ref_for_decl (tree decl, const char **sym,
   /* During WPA stage and incremental linking we currently use DIEs
      to store the decl <-> label + offset map.  That's quite inefficient
      but it works for now.  */
-  if (flag_wpa
-      || flag_incremental_link == INCREMENTAL_LINK_LTO)
+  if (in_lto_p)
     {
       dw_die_ref ref = get_AT_ref (die, DW_AT_abstract_origin);
       if (!ref)
index 91e8647d42a62f38f5576d5d27c1fef6e5853722..209a83897647dbba4661c1c54e2d88f542ce7841 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-20  Richard Biener  <rguenther@suse.de>
+
+       PR debug/86585
+       * lto.c (unify_scc): Before we throw away an SCC see if we
+       can amend prevailing single-entry SCC with debug refs.
+
 2018-07-13  Jan Hubicka  <hubicka@ucw.cz>
 
        * lto.c (do_stream_out): Add PART parameter; open dump file.
index d1add15efeb81f912cf061d00be32c3f70be1f6b..8db280ecefc7ba7e894d5f43fd3b789f6eea5f74 100644 (file)
@@ -1638,6 +1638,21 @@ unify_scc (struct data_in *data_in, unsigned from,
             to the tree node mapping computed by compare_tree_sccs.  */
          if (len == 1)
            {
+             /* If we got a debug reference queued, see if the prevailing
+                tree has a debug reference and if not, register the one
+                for the tree we are about to throw away.  */
+             if (dref_queue.length () == 1)
+               {
+                 dref_entry e = dref_queue.pop ();
+                 gcc_assert (e.decl
+                             == streamer_tree_cache_get_tree (cache, from));
+                 const char *sym;
+                 unsigned HOST_WIDE_INT off;
+                 if (!debug_hooks->die_ref_for_decl (pscc->entries[0], &sym,
+                                                     &off))
+                   debug_hooks->register_external_die (pscc->entries[0],
+                                                       e.sym, e.off);
+               }
              lto_maybe_register_decl (data_in, pscc->entries[0], from);
              streamer_tree_cache_replace_tree (cache, pscc->entries[0], from);
            }
@@ -1669,7 +1684,9 @@ unify_scc (struct data_in *data_in, unsigned from,
              free_node (scc->entries[i]);
            }
 
-         /* Drop DIE references.  */
+         /* Drop DIE references.
+            ???  Do as in the size-one SCC case which involves sorting
+            the queue.  */
          dref_queue.truncate (0);
 
          break;
index 8eccef11066b62c67d3787700f198dd8df48fa25..10c547c7d14cf0a7b1259396918debde4385044c 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-20  Richard Biener  <rguenther@suse.de>
+
+       PR debug/86585
+       * g++.dg/lto/pr86585_0.C: New testcase.
+       * g++.dg/lto/pr86585_1.C: Likewise.
+
 2018-07-19  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/83776
diff --git a/gcc/testsuite/g++.dg/lto/pr86585_0.C b/gcc/testsuite/g++.dg/lto/pr86585_0.C
new file mode 100644 (file)
index 0000000..2c3ae9d
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-lto-do link }
+// { dg-require-effective-target fpic }
+// { dg-require-effective-target shared }
+// { dg-lto-options { { -flto -g -nostdlib -shared -fPIC } } }
+namespace Inkscape {
+    class a;
+}
+class b {
+    Inkscape::a *c;
+    virtual void d();
+};
+class e {
+    b f;
+};
+class g : e {
+    void h();
+};
+void g::h() {}
diff --git a/gcc/testsuite/g++.dg/lto/pr86585_1.C b/gcc/testsuite/g++.dg/lto/pr86585_1.C
new file mode 100644 (file)
index 0000000..ebcbe12
--- /dev/null
@@ -0,0 +1,24 @@
+struct a {
+    struct b {
+       b();
+    } c;
+};
+class d {
+    a e;
+};
+namespace aa {
+    class h {};
+} // namespace aa
+class k {
+    typedef aa::h f;
+    f g;
+};
+namespace Inkscape {
+    class l {
+       k i;
+class : d {
+       } j;
+       l();
+    };
+    l::l() {}
+} // namespace Inkscape