[llvm] 30a8865 - [FastISel] Lower `llvm.dbg.value(undef, ...` correctly.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 16:22:45 PST 2020


Author: Davide Italiano
Date: 2020-01-16T16:22:20-08:00
New Revision: 30a8865142abe309bb9aceede2708c171a2904ea

URL: https://github.com/llvm/llvm-project/commit/30a8865142abe309bb9aceede2708c171a2904ea
DIFF: https://github.com/llvm/llvm-project/commit/30a8865142abe309bb9aceede2708c171a2904ea.diff

LOG: [FastISel] Lower `llvm.dbg.value(undef, ...` correctly.

Summary:
Instead of just dropping them.

<rdar://problem/58657146>

Reviewers: aprantl, vsk, ab, paquette, echristo

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

Added: 
    llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll

Modified: 
    llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 2bec8613e79c..9cd0e93f8615 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1412,9 +1412,9 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
     const Value *V = DI->getValue();
     assert(DI->getVariable()->isValidLocationForIntrinsic(DbgLoc) &&
            "Expected inlined-at fields to agree");
-    if (!V) {
+    if (!V || isa<UndefValue>(V)) {
       // Currently the optimizer can produce this; insert an undef to
-      // help debugging.  Probably the optimizer should not do this.
+      // help debugging.
       BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, false, 0U,
               DI->getVariable(), DI->getExpression());
     } else if (const auto *CI = dyn_cast<ConstantInt>(V)) {
@@ -1442,8 +1442,7 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
       BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg,
               DI->getVariable(), DI->getExpression());
     } else {
-      // We can't yet handle anything else here because it would require
-      // generating code, thus altering codegen because of debug info.
+      // We don't know how to handle other cases, so we drop.
       LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n");
     }
     return true;

diff  --git a/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll b/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll
new file mode 100644
index 000000000000..86aa7d15edbb
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll
@@ -0,0 +1,30 @@
+; RUN: llc -O0 -fast-isel=1 -o - -print-after="finalize-isel" %s 2>&1 | FileCheck %s
+
+; Check that we emit a DBG_VALUE for the `@llvm.dbg.value` which has `undef` has first arg.
+
+target triple = "arm64-apple-ios13.4.0"
+define void @foo() !dbg !6 {
+  ; CHECK: DBG_VALUE $noreg, $noreg, !"1", !DIExpression()
+  call void @llvm.dbg.value(metadata i32* undef, metadata !9, metadata !DIExpression()), !dbg !11
+  ret void, !dbg !12
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!3, !4}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "t.ll", directory: "/")
+!2 = !{}
+!3 = !{i32 2}
+!4 = !{i32 1}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
+!7 = !DISubroutineType(types: !2)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
+!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
+!11 = !DILocation(line: 1, column: 1, scope: !6)
+!12 = !DILocation(line: 2, column: 1, scope: !6)


        


More information about the llvm-commits mailing list