aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/IfConversion.cpp
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2017-05-29 06:12:18 +0000
committerTobias Grosser <tobias@grosser.es>2017-05-29 06:12:18 +0000
commit8cf785f6b19cf7a3dac9cda4fd386a876c0f108d (patch)
tree098765bbd11574ff5a8fc2313a5059e076e14983 /llvm/lib/CodeGen/IfConversion.cpp
parent6aa9e9b41a578cc086684d76e70660dfb162d421 (diff)
downloadllvm-8cf785f6b19cf7a3dac9cda4fd386a876c0f108d.zip
llvm-8cf785f6b19cf7a3dac9cda4fd386a876c0f108d.tar.gz
llvm-8cf785f6b19cf7a3dac9cda4fd386a876c0f108d.tar.bz2
Revert "[IfConversion] Keep the CFG updated incrementally in IfConvertTriangle"
The reverted change introdued assertions ala: "MachineBasicBlock::succ_iterator llvm::MachineBasicBlock::removeSuccessor(succ_iterator, bool): Assertion `I != Successors.end() && "Not a current successor!"' Mikael, the original committer, wrote me that he is working on a fix, but that it likely will take some time to get this resolved. As this bug is one of the last two issues that keep the AOSP buildbot from turning green, I revert the original commit r302876. I am looking forward to see this recommitted after the assertion has been resolved. llvm-svn: 304128
Diffstat (limited to 'llvm/lib/CodeGen/IfConversion.cpp')
-rw-r--r--llvm/lib/CodeGen/IfConversion.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index 8f3b6f9..1c33f3b 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -1588,32 +1588,22 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) {
BBCvt = MBPI->getEdgeProbability(BBI.BB, &CvtMBB);
}
- // To be able to insert code freely at the end of BBI we sometimes remove
- // the branch from BBI to NextMBB temporarily. Remember if this happened.
- bool RemovedBranchToNextMBB = false;
if (CvtMBB.pred_size() > 1) {
BBI.NonPredSize -= TII->removeBranch(*BBI.BB);
// Copy instructions in the true block, predicate them, and add them to
// the entry block.
CopyAndPredicateBlock(BBI, *CvtBBI, Cond, true);
- // Keep the CFG updated.
+ // RemoveExtraEdges won't work if the block has an unanalyzable branch, so
+ // explicitly remove CvtBBI as a successor.
BBI.BB->removeSuccessor(&CvtMBB, true);
} else {
// Predicate the 'true' block after removing its branch.
CvtBBI->NonPredSize -= TII->removeBranch(CvtMBB);
PredicateBlock(*CvtBBI, CvtMBB.end(), Cond);
- // Remove the branch from the entry of the triangle to NextBB to be able to
- // do the merge below. Keep the CFG updated, but remember we removed the
- // branch since we do want to execute NextMBB, either by introducing a
- // branch to it again, or merging it into the entry block.
- // How it's handled is decided further down.
- BBI.NonPredSize -= TII->removeBranch(*BBI.BB);
- BBI.BB->removeSuccessor(&NextMBB, true);
- RemovedBranchToNextMBB = true;
-
// Now merge the entry of the triangle with the true block.
+ BBI.NonPredSize -= TII->removeBranch(*BBI.BB);
MergeBlocks(BBI, *CvtBBI, false);
}
@@ -1651,19 +1641,12 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) {
// block. By not merging them, we make it possible to iteratively
// ifcvt the blocks.
if (!HasEarlyExit &&
- // We might have removed BBI from NextMBB's predecessor list above but
- // we want it to be there, so consider that too.
- (NextMBB.pred_size() == (RemovedBranchToNextMBB ? 0 : 1)) &&
- !NextBBI->HasFallThrough &&
+ NextMBB.pred_size() == 1 && !NextBBI->HasFallThrough &&
!NextMBB.hasAddressTaken()) {
- // We will merge NextBBI into BBI, and thus remove the current
- // fallthrough from BBI into CvtBBI.
- BBI.BB->removeSuccessor(&CvtMBB, true);
MergeBlocks(BBI, *NextBBI);
FalseBBDead = true;
} else {
InsertUncondBranch(*BBI.BB, NextMBB, TII);
- BBI.BB->addSuccessor(&NextMBB);
BBI.HasFallThrough = false;
}
// Mixed predicated and unpredicated code. This cannot be iteratively
@@ -1671,6 +1654,8 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) {
IterIfcvt = false;
}
+ RemoveExtraEdges(BBI);
+
// Update block info. BB can be iteratively if-converted.
if (!IterIfcvt)
BBI.IsDone = true;