[PATCH] debug/97718 - fix abstract origin references after last change

Richard Biener rguenther@suse.de
Thu Nov 5 09:20:17 GMT 2020


The change to clear the external_die_map slot after creating
the concrete instance DIE broke abstract origin processing which
tried to make sure to have those point to the early abstract instance
and not the concrete instance.  The following restores this by
eventually following the abstract origin link in the concrete instance.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

2020-11-05  Richard Biener  <rguenther@suse.de>

	PR debug/97718
	* dwarf2out.c (add_abstract_origin_attribute): Make sure to
	point to the abstract instance.
---
 gcc/dwarf2out.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 64ac94a8cbd..81cb7341a7e 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -21293,7 +21293,16 @@ add_abstract_origin_attribute (dw_die_ref die, tree origin)
      here.  */
 
   if (origin_die)
-    add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
+    {
+      dw_attr_node *a;
+      /* Like above, if we already created a concrete instance DIE
+	 do not use that for the abstract origin but the early DIE
+	 if present.  */
+      if (in_lto_p
+	  && (a = get_AT (origin_die, DW_AT_abstract_origin)))
+	origin_die = AT_ref (a);
+      add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
+    }
 }
 
 /* We do not currently support the pure_virtual attribute.  */
-- 
2.26.2


More information about the Gcc-patches mailing list