[llvm] r319674 - MachineVerifier: undef phi arg doesn't need to be live-out from predecessor
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 10:57:48 PST 2017
Author: matze
Date: Mon Dec 4 10:57:48 2017
New Revision: 319674
URL: http://llvm.org/viewvc/llvm-project?rev=319674&view=rev
Log:
MachineVerifier: undef phi arg doesn't need to be live-out from predecessor
Differential Revision: https://reviews.llvm.org/D40756
Added:
llvm/trunk/test/CodeGen/X86/verifier-phi-fail0.mir
llvm/trunk/test/CodeGen/X86/verifier-phi.mir
Modified:
llvm/trunk/lib/CodeGen/MachineVerifier.cpp
Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=319674&r1=319673&r2=319674&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Mon Dec 4 10:57:48 2017
@@ -1652,7 +1652,8 @@ void MachineVerifier::checkPHIOps(const
if (MInfo.reachable) {
seen.insert(&Pre);
BBInfo &PrInfo = MBBInfoMap[&Pre];
- if (PrInfo.reachable && !PrInfo.isLiveOut(MO0.getReg()))
+ if (!MO0.isUndef() && PrInfo.reachable &&
+ !PrInfo.isLiveOut(MO0.getReg()))
report("PHI operand is not live-out from predecessor", &MO0, I);
}
}
Added: llvm/trunk/test/CodeGen/X86/verifier-phi-fail0.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/verifier-phi-fail0.mir?rev=319674&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/verifier-phi-fail0.mir (added)
+++ llvm/trunk/test/CodeGen/X86/verifier-phi-fail0.mir Mon Dec 4 10:57:48 2017
@@ -0,0 +1,30 @@
+# RUN: not llc -o - %s -verify-machineinstrs -run-pass=none 2>&1 | FileCheck %s
+---
+# CHECK: Bad machine code: PHI operand is not live-out from predecessor
+# CHECK: - function: func0
+# CHECK: - basic block: %bb.3
+# CHECK: - instruction: %0<def> = PHI
+# CHECK: - operand 1: %1
+#
+# CHECK: Bad machine code: PHI operand is not live-out from predecessor
+# CHECK: - function: func0
+# CHECK: - basic block: %bb.3
+# CHECK: - instruction: %0<def> = PHI
+# CHECK: - operand 3: %0
+name: func0
+tracksRegLiveness: true
+body: |
+ bb.0:
+ JE_1 %bb.1, implicit undef %eflags
+ JMP_1 %bb.2
+
+ bb.1:
+ %0:gr32 = IMPLICIT_DEF
+ JMP_1 %bb.3
+
+ bb.2:
+ %1:gr32 = IMPLICIT_DEF
+
+ bb.3:
+ %0:gr32 = PHI %1, %bb.1, %0, %bb.2
+...
Added: llvm/trunk/test/CodeGen/X86/verifier-phi.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/verifier-phi.mir?rev=319674&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/verifier-phi.mir (added)
+++ llvm/trunk/test/CodeGen/X86/verifier-phi.mir Mon Dec 4 10:57:48 2017
@@ -0,0 +1,34 @@
+# RUN: llc -o - %s -verify-machineinstrs -run-pass=none | FileCheck %s
+# This should cleanly pass the machine verifier
+---
+# CHECK-LABEL: name: func0
+# CHECK: %0:gr32 = PHI undef %1:gr32, %bb.0, undef %1:gr32, %bb.1
+name: func0
+tracksRegLiveness: true
+body: |
+ bb.0:
+ JE_1 %bb.1, implicit undef %eflags
+ JMP_1 %bb.2
+
+ bb.1:
+
+ bb.2:
+ %0 : gr32 = PHI undef %1 : gr32, %bb.0, undef %1 : gr32, %bb.1
+...
+---
+# CHECK-LABEL: name: func1
+# CHECK: %2:gr32 = PHI %0, %bb.0, %1, %bb.1
+name: func1
+tracksRegLiveness: true
+body: |
+ bb.0:
+ %0 : gr32 = IMPLICIT_DEF
+ JE_1 %bb.1, implicit undef %eflags
+ JMP_1 %bb.2
+
+ bb.1:
+ %1 : gr32 = IMPLICIT_DEF
+
+ bb.2:
+ %2 : gr32 = PHI %0, %bb.0, %1, %bb.1
+...
More information about the llvm-commits
mailing list