summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2018-10-03 22:05:31 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2018-10-03 22:05:31 +0000
commit1b493739e040867eb399be4a2e0b776a8403e471 (patch)
treedf07a13e1cf15fe82be24f1351bb92b3a6d465df /llvm/lib/CodeGen
parent757270435c4eb8c1bf8524dd8dcee4449fbae3a2 (diff)
downloadbcm5719-llvm-1b493739e040867eb399be4a2e0b776a8403e471.tar.gz
bcm5719-llvm-1b493739e040867eb399be4a2e0b776a8403e471.zip
[machineverifier] Detect PHI's that are preceeded by non-PHI's
If present, PHI nodes must appear before non-PHI nodes in a basic block. The register allocator relies on this and will fail to eliminate PHI's that do not meet this requirement. llvm-svn: 343731
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index e8de966b5e1..a19c2ef8002 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -109,6 +109,7 @@ namespace {
using RegMap = DenseMap<unsigned, const MachineInstr *>;
using BlockSet = SmallPtrSet<const MachineBasicBlock *, 8>;
+ const MachineInstr *FirstNonPHI;
const MachineInstr *FirstTerminator;
BlockSet FunctionBlocks;
@@ -608,6 +609,7 @@ static bool matchPair(MachineBasicBlock::const_succ_iterator i,
void
MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
FirstTerminator = nullptr;
+ FirstNonPHI = nullptr;
if (!MF->getProperties().hasProperty(
MachineFunctionProperties::Property::NoPHIs) && MRI->tracksLiveness()) {
@@ -889,9 +891,15 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
<< MI->getNumOperands() << " given.\n";
}
- if (MI->isPHI() && MF->getProperties().hasProperty(
- MachineFunctionProperties::Property::NoPHIs))
- report("Found PHI instruction with NoPHIs property set", MI);
+ if (MI->isPHI()) {
+ if (MF->getProperties().hasProperty(
+ MachineFunctionProperties::Property::NoPHIs))
+ report("Found PHI instruction with NoPHIs property set", MI);
+
+ if (FirstNonPHI)
+ report("Found PHI instruction after non-PHI", MI);
+ } else if (FirstNonPHI == nullptr)
+ FirstNonPHI = MI;
// Check the tied operands.
if (MI->isInlineAsm())
OpenPOWER on IntegriCloud