[llvm] [llvm] Fix assertion error where we didn't check fixed point types. (PR #80757)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 16:20:46 PST 2024


https://github.com/PiJoules updated https://github.com/llvm/llvm-project/pull/80757

>From de5967f0c4cdcca5824e9c29c945d261b5ac8ef3 Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Mon, 5 Feb 2024 14:55:34 -0800
Subject: [PATCH] [llvm] Fix assertion error where we didn't check fixed point
 types.

---
 .../CodeGen/AsmPrinter/DebugHandlerBase.cpp   |  3 +++
 llvm/test/DebugInfo/fixed-point.ll            | 26 +++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 llvm/test/DebugInfo/fixed-point.ll

diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index eb2d992c7e75e7..f00ff1565c665f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -224,12 +224,15 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
           Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
           Encoding == dwarf::DW_ATE_boolean ||
           Encoding == dwarf::DW_ATE_complex_float ||
+          Encoding == dwarf::DW_ATE_signed_fixed ||
+          Encoding == dwarf::DW_ATE_unsigned_fixed ||
           (Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
            Ty->getName() == "decltype(nullptr)")) &&
          "Unsupported encoding");
   return Encoding == dwarf::DW_ATE_unsigned ||
          Encoding == dwarf::DW_ATE_unsigned_char ||
          Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
+         Encoding == llvm::dwarf::DW_ATE_unsigned_fixed ||
          Ty->getTag() == dwarf::DW_TAG_unspecified_type;
 }
 
diff --git a/llvm/test/DebugInfo/fixed-point.ll b/llvm/test/DebugInfo/fixed-point.ll
new file mode 100644
index 00000000000000..25024df2972007
--- /dev/null
+++ b/llvm/test/DebugInfo/fixed-point.ll
@@ -0,0 +1,26 @@
+;; This fixes https://github.com/llvm/llvm-project/issues/81555
+;; Note this isn't correct dwarf but we just need to assert this doesn't crash.
+; RUN: %llc_dwarf %s -filetype=obj
+
+define void @func() !dbg !26 {
+entry:
+  %classifier = alloca i32, align 4
+  tail call void @llvm.dbg.value(metadata i32 32768, metadata !37, metadata !DIExpression()), !dbg !39
+  store i32 32768, ptr %classifier, align 4, !dbg !39
+  ret void
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!19}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "a", directory: "")
+!6 = !DIBasicType(name: "", size: 32, encoding: DW_ATE_signed_fixed)
+!19 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !DISubroutineType(types: null)
+!26 = distinct !DISubprogram(unit: !0, type: !3)
+!37 = !DILocalVariable(name: "intercept", arg: 2, scope: !26, file: !1, line: 7, type: !6)
+!39 = !DILocation(line: 0, scope: !26)
+



More information about the llvm-commits mailing list