[PATCH] D151795: [DebugInfo] Add DW_ATE_complex_float case to assert in isUnsignedDIType

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 04:35:09 PDT 2023


Orlando created this revision.
Orlando added reviewers: jmorse, dblaikie, hctim.
Orlando added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Without this patch a `DW_ATE_complex_float` encoding trips an assertion in `DebugHandlerBase::isUnsignedDIType`. The assertion message `"Unsupported encoding"` possibly indicates that either the encoding either truly isn't supported or hasn't yet had support added.

By adding a case to the `assert` for `DW_ATE_complex_float` it becomes supported, behaving in the same way as the already supported `DW_ATE_float` type (return false), which I think makes sense.

That resolves this issue <https://reviews.llvm.org/D146987#4375881> mentioned in D146987 <https://reviews.llvm.org/D146987>.

Note: For the reported reproducer:

  #include <complex.h>
  int main() {
    long double complex r1;
  }

The assertion isn't tripped without assignment tracking because instcombine deletes everything, including the `dbg.declare`, without recovering any location information. Whereas with assignment tracking we track a zeroing memset that is emitted by clang.


https://reviews.llvm.org/D151795

Files:
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll


Index: llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll
@@ -0,0 +1,35 @@
+; RUN: llc %s -filetype=asm -o - | FileCheck %s
+
+;; Check a single location variable of type DW_ATE_complex_float with a
+;; constant value is emitted with a DW_AT_const_value attribute.
+
+; CHECK: .Ldebug_info_start0:
+; CHECK: .byte 0 # DW_AT_const_value
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define dso_local void @f() local_unnamed_addr !dbg !10 {
+entry:
+  call void @llvm.dbg.value(metadata i8 0, metadata !14, metadata !DIExpression()), !dbg !17
+  ret void, !dbg !19
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "test.c", directory: "/")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{!"clang version 17.0.0"}
+!10 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !11, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!11 = !DISubroutineType(types: !12)
+!12 = !{null}
+!13 = !{!14}
+!14 = !DILocalVariable(name: "r1", scope: !10, file: !1, line: 3, type: !15)
+!15 = !DIBasicType(name: "complex", size: 128, encoding: DW_ATE_complex_float)
+!17 = !DILocation(line: 0, scope: !10)
+!19 = !DILocation(line: 4, column: 1, scope: !10)
Index: llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -223,6 +223,7 @@
           Encoding == dwarf::DW_ATE_signed_char ||
           Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
           Encoding == dwarf::DW_ATE_boolean ||
+          Encoding == dwarf::DW_ATE_complex_float ||
           (Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
            Ty->getName() == "decltype(nullptr)")) &&
          "Unsupported encoding");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151795.526991.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230531/db130066/attachment.bin>


More information about the llvm-commits mailing list