summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp')
-rw-r--r--llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp b/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
index 0e5780ebec4..31b3ceac541 100644
--- a/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ b/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -1374,9 +1374,8 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
// to isolate ourselves from the rest of LLVM and for simplicity. Here we can
// egregiously cheat based on knowledge of the test case. For example, we
// have no PHI nodes and there is always a single i-dom.
- auto RemoveLoop = [](Loop &L, BasicBlock &IDomBB,
- LoopStandardAnalysisResults &AR,
- LPMUpdater &Updater) {
+ auto EraseLoop = [](Loop &L, BasicBlock &IDomBB,
+ LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
assert(L.empty() && "Can only delete leaf loops with this routine!");
SmallVector<BasicBlock *, 4> LoopBBs(L.block_begin(), L.block_end());
Updater.markLoopAsDeleted(L);
@@ -1394,10 +1393,7 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
for (BasicBlock *LoopBB : LoopBBs)
LoopBB->eraseFromParent();
- if (Loop *ParentL = L.getParentLoop())
- return ParentL->removeChildLoop(find(*ParentL, &L));
-
- return AR.LI.removeLoop(find(AR.LI, &L));
+ AR.LI.markAsErased(&L);
};
// Build up the pass managers.
@@ -1442,7 +1438,7 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
Loop *ParentL = L.getParentLoop();
AR.SE.forgetLoop(&L);
- delete RemoveLoop(L, Loop01PHBB, AR, Updater);
+ EraseLoop(L, Loop01PHBB, AR, Updater);
ParentL->verifyLoop();
return PreservedAnalyses::all();
}));
@@ -1469,10 +1465,8 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
.WillRepeatedly(Invoke(getLoopAnalysisResult));
// Run the loop pipeline again. This time we delete the last loop, which
- // contains a nested loop within it, and we reuse its inner loop object to
- // insert a new loop into the nest. This makes sure that we don't reuse
- // cached analysis results for loop objects when removed just because their
- // pointers match, and that we can handle nested loop deletion.
+ // contains a nested loop within it and insert a new loop into the nest. This
+ // makes sure we can handle nested loop deletion.
AddLoopPipelineAndVerificationPasses();
EXPECT_CALL(MLPHandle, run(HasName("loop.0.0"), _, _, _))
.Times(3)
@@ -1489,16 +1483,16 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
.WillOnce(
Invoke([&](Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
- // Remove the inner loop first but retain it to reuse later.
AR.SE.forgetLoop(*L.begin());
- auto *OldL = RemoveLoop(**L.begin(), Loop020PHBB, AR, Updater);
+ EraseLoop(**L.begin(), Loop020PHBB, AR, Updater);
auto *ParentL = L.getParentLoop();
AR.SE.forgetLoop(&L);
- delete RemoveLoop(L, Loop02PHBB, AR, Updater);
+ EraseLoop(L, Loop02PHBB, AR, Updater);
- // Now insert a new sibling loop, reusing a loop pointer.
- ParentL->addChildLoop(OldL);
+ // Now insert a new sibling loop.
+ auto *NewSibling = new Loop;
+ ParentL->addChildLoop(NewSibling);
NewLoop03PHBB =
BasicBlock::Create(Context, "loop.0.3.ph", &F, &Loop0LatchBB);
auto *NewLoop03BB =
@@ -1515,10 +1509,10 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
AR.DT[NewLoop03BB]);
AR.DT.verifyDomTree();
ParentL->addBasicBlockToLoop(NewLoop03PHBB, AR.LI);
- OldL->addBasicBlockToLoop(NewLoop03BB, AR.LI);
- OldL->verifyLoop();
+ NewSibling->addBasicBlockToLoop(NewLoop03BB, AR.LI);
+ NewSibling->verifyLoop();
ParentL->verifyLoop();
- Updater.addSiblingLoops({OldL});
+ Updater.addSiblingLoops({NewSibling});
return PreservedAnalyses::all();
}));
@@ -1550,7 +1544,7 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
Invoke([&](Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
AR.SE.forgetLoop(&L);
- delete RemoveLoop(L, Loop00PHBB, AR, Updater);
+ EraseLoop(L, Loop00PHBB, AR, Updater);
return PreservedAnalyses::all();
}));
@@ -1561,7 +1555,7 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
Invoke([&](Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
AR.SE.forgetLoop(&L);
- delete RemoveLoop(L, *NewLoop03PHBB, AR, Updater);
+ EraseLoop(L, *NewLoop03PHBB, AR, Updater);
return PreservedAnalyses::all();
}));
@@ -1572,7 +1566,7 @@ TEST_F(LoopPassManagerTest, LoopDeletion) {
Invoke([&](Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &Updater) {
AR.SE.forgetLoop(&L);
- delete RemoveLoop(L, EntryBB, AR, Updater);
+ EraseLoop(L, EntryBB, AR, Updater);
return PreservedAnalyses::all();
}));
OpenPOWER on IntegriCloud