[llvm] 9dcae2f - [DebugInfo] Add DW_ATE_complex_float case to assert in isUnsignedDIType

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 09:10:17 PDT 2023


Author: OCHyams
Date: 2023-06-12T17:09:04+01:00
New Revision: 9dcae2f524e7bd9c6655778fb3c4c5cac05180cb

URL: https://github.com/llvm/llvm-project/commit/9dcae2f524e7bd9c6655778fb3c4c5cac05180cb
DIFF: https://github.com/llvm/llvm-project/commit/9dcae2f524e7bd9c6655778fb3c4c5cac05180cb.diff

LOG: [DebugInfo] Add DW_ATE_complex_float case to assert in isUnsignedDIType

Without this patch a `DW_ATE_complex_float` encoding trips an assertion in
`DebugHandlerBase::isUnsignedDIType` with the message `"Unsupported
encoding"`.

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).

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.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D151795

Added: 
    llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 1f1d2430aa0eb..eb2d992c7e75e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -223,6 +223,7 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
           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");

diff  --git a/llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll b/llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll
new file mode 100644
index 0000000000000..bee40242eb375
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/DW_ATE_complex_float.ll
@@ -0,0 +1,44 @@
+; RUN: llc %s -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.
+
+;; Modified from C source input:
+;; #include <complex.h>
+;; void f() { double complex r1; }
+
+; CHECK: .Ldebug_info_start0:
+; CHECK:      .byte [[#]]              # Abbrev {{.*}} DW_TAG_variable
+; CHECK-NEXT: .byte 0                  # DW_AT_const_value
+; CHECK-NEXT: .byte [[str_idx:[0-9]+]] # DW_AT_name
+
+; CHECK: .Linfo_string[[str_idx]]:
+; CHECK-NEXT: .asciz "r1"
+
+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)


        


More information about the llvm-commits mailing list