summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-02-21 19:54:05 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-02-21 19:54:05 +0000
commitd2d3244363b705dc8edfff2a7cabf8433cf76fc5 (patch)
tree460990b5c5801d877e66ee964b3225dd61b59f2b /llvm/lib/Transforms
parent73446cd567af35184e64577357efbd31996c4776 (diff)
downloadbcm5719-llvm-d2d3244363b705dc8edfff2a7cabf8433cf76fc5.tar.gz
bcm5719-llvm-d2d3244363b705dc8edfff2a7cabf8433cf76fc5.zip
[LoopSimplifyCFG] Update MemorySSA after r353911.
Summary: MemorySSA is not properly updated in LoopSimplifyCFG after recent changes. Use SplitBlock utility to resolve that and clear all updates once handleDeadExits is finished. All updates that follow are removal of edges which are safe to handle via the removeEdge() API. Also, deleting dead blocks is done correctly as is, i.e. delete from MemorySSA before updating the CFG and DT. Reviewers: mkazantsev, rtereshin Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58524 llvm-svn: 354613
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
index bbf35513416..b565cb9c236 100644
--- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
@@ -352,14 +352,9 @@ private:
// Construct split preheader and the dummy switch to thread edges from it to
// dead exits.
BasicBlock *Preheader = L.getLoopPreheader();
- BasicBlock *NewPreheader = Preheader->splitBasicBlock(
- Preheader->getTerminator(),
- Twine(Preheader->getName()).concat("-split"));
- if (MSSAU)
- MSSAU->removeEdge(Preheader, L.getHeader());
- DTUpdates.push_back({DominatorTree::Delete, Preheader, L.getHeader()});
- DTUpdates.push_back({DominatorTree::Insert, NewPreheader, L.getHeader()});
- DTUpdates.push_back({DominatorTree::Insert, Preheader, NewPreheader});
+ BasicBlock *NewPreheader = llvm::SplitBlock(
+ Preheader, Preheader->getTerminator(), &DT, &LI, MSSAU);
+
IRBuilder<> Builder(Preheader->getTerminator());
SwitchInst *DummySwitch =
Builder.CreateSwitch(Builder.getInt32(0), NewPreheader);
@@ -384,8 +379,6 @@ private:
assert(L.getLoopPreheader() == NewPreheader && "Malformed CFG?");
if (Loop *OuterLoop = LI.getLoopFor(Preheader)) {
- OuterLoop->addBasicBlockToLoop(NewPreheader, LI);
-
// When we break dead edges, the outer loop may become unreachable from
// the current loop. We need to fix loop info accordingly. For this, we
// find the most nested loop that still contains L and remove L from all
@@ -414,10 +407,21 @@ private:
assert(FixLCSSALoop && "Should be a loop!");
// We need all DT updates to be done before forming LCSSA.
DTU.applyUpdates(DTUpdates);
+ if (MSSAU)
+ MSSAU->applyUpdates(DTUpdates, DT);
DTUpdates.clear();
formLCSSARecursively(*FixLCSSALoop, DT, &LI, &SE);
}
}
+
+ if (MSSAU) {
+ // Clear all updates now. Facilitates deletes that follow.
+ DTU.applyUpdates(DTUpdates);
+ MSSAU->applyUpdates(DTUpdates, DT);
+ DTUpdates.clear();
+ if (VerifyMemorySSA)
+ MSSAU->getMemorySSA()->verifyMemorySSA();
+ }
}
/// Delete loop blocks that have become unreachable after folding. Make all
@@ -589,6 +593,9 @@ public:
DTUpdates.clear();
}
+ if (MSSAU && VerifyMemorySSA)
+ MSSAU->getMemorySSA()->verifyMemorySSA();
+
#ifndef NDEBUG
// Make sure that we have preserved all data structures after the transform.
assert(DT.verify() && "DT broken after transform!");
OpenPOWER on IntegriCloud