]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Assert we don't create recursive DW_AT_{abstract_origin,specification}
authorRichard Biener <rguenther@suse.de>
Mon, 30 Oct 2023 12:17:11 +0000 (13:17 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 17 Nov 2023 07:53:51 +0000 (08:53 +0100)
We have a support case that shows GCC 7 sometimes creates
DW_TAG_label refering to itself via a DW_AT_abstract_origin
when using LTO.  This for example triggers the sanity check
added below during LTO bootstrap.

Making this check cover more than just DW_AT_abstract_origin
breaks bootstrap on trunk for

      /* GNU extension: Record what type our vtable lives in.  */
      if (TYPE_VFIELD (type))
        {
          tree vtype = DECL_FCONTEXT (TYPE_VFIELD (type));

          gen_type_die (vtype, context_die);
          add_AT_die_ref (type_die, DW_AT_containing_type,
                          lookup_type_die (vtype));

so the check is for now restricted to DW_AT_abstract_origin
and DW_AT_specification both of which we follow within get_AT.

* dwarf2out.cc (add_AT_die_ref): Assert we do not add
a self-ref DW_AT_abstract_origin or DW_AT_specification.

gcc/dwarf2out.cc

index 9850d094707e563a79fdefa65a176ad513260cda..d187be9b78632a9e397207bb51824335100c4373 100644 (file)
@@ -4908,6 +4908,9 @@ add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_
 {
   dw_attr_node attr;
   gcc_checking_assert (targ_die != NULL);
+  gcc_assert (targ_die != die
+             || (attr_kind != DW_AT_abstract_origin
+                 && attr_kind != DW_AT_specification));
 
   /* 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.  */