[all-commits] [llvm/llvm-project] ca715d: [llvm][DebugInfo] Add DW_AT_type to DW_TAG_enumera...

David Spickett via All-commits all-commits at lists.llvm.org
Fri Jul 12 01:42:52 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca715de4bcf31085ee7a35aaf60843e994801f10
      https://github.com/llvm/llvm-project/commit/ca715de4bcf31085ee7a35aaf60843e994801f10
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2024-07-12 (Fri, 12 Jul 2024)

  Changed paths:
    M llvm/docs/ReleaseNotes.rst
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/test/DebugInfo/Generic/debug-info-enum.ll
    M llvm/test/DebugInfo/X86/dbg-rust-valid-enum-as-scope.ll

  Log Message:
  -----------
  [llvm][DebugInfo] Add DW_AT_type to DW_TAG_enumeration_type in non-strict DWARF v2 mode (#98335)

During testing of https://github.com/llvm/llvm-project/pull/96202 we
found that when clang set to DWARF v2 was used to build the test file,
lldb could not tell that the unsigned enum type was in fact unsigned. So
it defaulted to signed and printed the wrong value.

The reason for this is that DWARFv2 does not include DW_AT_type in
DW_TAG_enumeration_type. This was added in DWARF v3:
"The enumeration type entry may also have a DW_AT_type attribute which
refers to the underlying data type used to implement the enumeration.

In C or C++, the underlying type will be the appropriate integral type
determined by the compiler from the properties of the enumeration
literal values."

I noticed that gcc does emit this attribute for DWARF v2 but not when
strict DWARF is requested (more details in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16063#c7).

This patch changes to clang to do the same. This will improve the
experience of anyone using tools that can understand the attribute but
for whatever reason are stuck building binaries containing v2 only.

You can see a current clang/gcc comparison here:
https://godbolt.org/z/eG9Kc9WGf

https://reviews.llvm.org/D42734 added the original code that emitted
this for >= v3 only.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list