Add test case for r311511
This also changes the TailDuplicator to be configured explicitely
pre/post regalloc rather than relying on the isSSA() flag. This was
necessary to have `llc -run-pass` work reliably.
llvm-svn: 311520
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 6533030..c30f306 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -2729,7 +2729,8 @@
MPDT = &getAnalysis<MachinePostDominatorTree>();
if (MF.getFunction()->optForSize())
TailDupSize = 1;
- TailDup.initMF(MF, MBPI, /* LayoutMode */ true, TailDupSize);
+ bool PreRegAlloc = false;
+ TailDup.initMF(MF, PreRegAlloc, MBPI, /* LayoutMode */ true, TailDupSize);
precomputeTriangleChains();
}
diff --git a/llvm/lib/CodeGen/TailDuplication.cpp b/llvm/lib/CodeGen/TailDuplication.cpp
index 489a607..131b9a2 100644
--- a/llvm/lib/CodeGen/TailDuplication.cpp
+++ b/llvm/lib/CodeGen/TailDuplication.cpp
@@ -52,7 +52,10 @@
auto MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
- Duplicator.initMF(MF, MBPI, /* LayoutMode */ false);
+ // TODO: Querying isSSA() to determine pre-/post-regalloc is fragile, better
+ // split this into two passes instead.
+ bool PreRegAlloc = MF.getRegInfo().isSSA();
+ Duplicator.initMF(MF, PreRegAlloc, MBPI, /* LayoutMode */ false);
bool MadeChange = false;
while (Duplicator.tailDuplicateBlocks())
diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp
index 0f22040..bd3a20f 100644
--- a/llvm/lib/CodeGen/TailDuplicator.cpp
+++ b/llvm/lib/CodeGen/TailDuplicator.cpp
@@ -75,7 +75,7 @@
static cl::opt<unsigned> TailDupLimit("tail-dup-limit", cl::init(~0U),
cl::Hidden);
-void TailDuplicator::initMF(MachineFunction &MFin,
+void TailDuplicator::initMF(MachineFunction &MFin, bool PreRegAlloc,
const MachineBranchProbabilityInfo *MBPIin,
bool LayoutModeIn, unsigned TailDupSizeIn) {
MF = &MFin;
@@ -89,7 +89,7 @@
assert(MBPI != nullptr && "Machine Branch Probability Info required");
LayoutMode = LayoutModeIn;
- PreRegAlloc = MRI->isSSA();
+ this->PreRegAlloc = PreRegAlloc;
}
static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) {