https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118837

--- Comment #6 from Tom Tromey <tromey at gcc dot gnu.org> ---
I also looked through the LLVM DWARF writer.

In part it is a bit nicer because it does:

void DwarfUnit::addConstantValue(DIE &Die, bool Unsigned, uint64_t Val) {
  // FIXME: This is a bit conservative/simple - it emits negative values always
  // sign extended to 64 bits rather than minimizing the number of bytes.
  addUInt(Die, dwarf::DW_AT_const_value,
          Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
}


That is, for this attribute at least, it doesn't try to compute
the narrowest possible form.

Looking at the other "confused" attributes:

        if (Offset < 0)
          addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
                  Offset);
        else
          addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
                  (uint64_t)Offset);

.. i.e., LLVM does the same as GCC here.

And finally:

      if (DD->getDwarfVersion() == 3)
        addUInt(MemberDie, dwarf::DW_AT_data_member_location,
                dwarf::DW_FORM_udata, OffsetInBytes);
      else
        addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
                OffsetInBytes);

... which is fine since it at least agrees with GCC that narrow
forms should not sign-extend.

Reply via email to