summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2017-09-19 23:19:00 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2017-09-19 23:19:00 +0000
commit76ab23234c5211b71962a1e4d0c4f3bf61f19b19 (patch)
tree5d8c195865be1f9a9011143a5680443cc5481845 /llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
parentfbfaec7089b8bfc1e3ef91dfbc50b4b7cf7a79e7 (diff)
downloadbcm5719-llvm-76ab23234c5211b71962a1e4d0c4f3bf61f19b19.tar.gz
bcm5719-llvm-76ab23234c5211b71962a1e4d0c4f3bf61f19b19.zip
[LoopInfo] Make LoopBase and Loop destructors non-public
Summary: See comment for why I think this is a good idea. This change also: - Removes an SCEV test case. The SCEV test was not testing anything useful (most of it was `#if 0` ed out) and it would need to be updated to deal with a private ~Loop::Loop. - Updates the loop pass manager test case to deal with a private ~Loop::Loop. - Renames markAsRemoved to markAsErased to contrast with removeLoop, via the usual remove vs. erase idiom we already have for instructions and basic blocks. Reviewers: chandlerc Subscribers: mehdi_amini, mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D37996 llvm-svn: 313695
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