[llvm] f002ee5 - [MachineVerifier] Remove placement rule exception for debug entry values

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 13:02:43 PST 2020


Author: Vedant Kumar
Date: 2020-03-03T13:02:18-08:00
New Revision: f002ee55c78147eefa3836660c55c5bc9d567fab

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

LOG: [MachineVerifier] Remove placement rule exception for debug entry values

There should not be an exception allowing debug entry values to be
placed after a terminator.

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

Added: 
    llvm/test/DebugInfo/MIR/AArch64/no-dbg-value-after-terminator.mir

Modified: 
    llvm/lib/CodeGen/MachineVerifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index f298ab811fd4..72da33c92346 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -838,7 +838,7 @@ void MachineVerifier::visitMachineBundleBefore(const MachineInstr *MI) {
   if (MI->isTerminator() && !TII->isPredicated(*MI)) {
     if (!FirstTerminator)
       FirstTerminator = MI;
-  } else if (FirstTerminator && !MI->isDebugEntryValue()) {
+  } else if (FirstTerminator) {
     report("Non-terminator instruction after the first terminator", MI);
     errs() << "First terminator was:\t" << *FirstTerminator;
   }

diff  --git a/llvm/test/DebugInfo/MIR/AArch64/no-dbg-value-after-terminator.mir b/llvm/test/DebugInfo/MIR/AArch64/no-dbg-value-after-terminator.mir
new file mode 100644
index 000000000000..14e979788abe
--- /dev/null
+++ b/llvm/test/DebugInfo/MIR/AArch64/no-dbg-value-after-terminator.mir
@@ -0,0 +1,48 @@
+# RUN: not llc -mtriple aarch64-linux-gnu -verify-machineinstrs -start-after=livedebugvalues \
+# RUN:   -filetype=obj -o /dev/null %s 2>&1 | FileCheck %s
+
+# CHECK: *** Bad machine code: Non-terminator instruction after the first terminator ***
+# CHECK-NEXT: - function:    f1
+# CHECK-NEXT: - basic block: %bb.0
+# CHECK-NEXT: - instruction: DBG_VALUE $noreg, $noreg, !"1", !DIExpression(DW_OP_LLVM_entry_value, 1)
+# CHECK-NEXT: First terminator was:   RET undef $lr, debug-location !12; /tmp/foo.ll:2:1
+
+--- |
+  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+  target triple = "aarch64"
+
+  define void @f1() !dbg !6 {
+    %add1 = add i32 0, 0, !dbg !11
+    call void @llvm.dbg.value(metadata i32 %add1, 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: "/tmp/foo.ll", directory: "/")
+  !2 = !{}
+  !3 = !{i32 2}
+  !4 = !{i32 1}
+  !5 = !{i32 2, !"Debug Info Version", i32 3}
+  !6 = distinct !DISubprogram(name: "f1", linkageName: "f1", 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: "ty32", size: 32, encoding: DW_ATE_unsigned)
+  !11 = !DILocation(line: 1, column: 1, scope: !6)
+  !12 = !DILocation(line: 2, column: 1, scope: !6)
+
+...
+---
+name:            f1
+body:             |
+  bb.0 (%ir-block.0):
+    RET undef $lr, debug-location !12
+    DBG_VALUE $noreg, $noreg, !9, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !11
+
+...


        


More information about the llvm-commits mailing list