diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2017-05-25 03:01:31 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2017-05-25 03:01:31 +0000 |
commit | 29c22d2835acf876c60e90c3f527bfc1b66c152f (patch) | |
tree | e0e8ab63b55d8e48d5e81bc848967480d171517e /llvm/lib/Analysis/LoopPass.cpp | |
parent | d5c65ffa8dd419b618b1c28602637d3e816d8a94 (diff) | |
download | bcm5719-llvm-29c22d2835acf876c60e90c3f527bfc1b66c152f.tar.gz bcm5719-llvm-29c22d2835acf876c60e90c3f527bfc1b66c152f.zip |
[LegacyPM] Make the 'addLoop' method accept a loop to add rather than
having it internally allocate the loop.
This is a much more flexible API and necessary in the new loop unswitch
to reasonably support both new and old PMs in common code. It also just
seems like a cleaner separation of concerns.
NFC, this should just be a pure refactoring.
Differential Revision: https://reviews.llvm.org/D33528
llvm-svn: 303834
Diffstat (limited to 'llvm/lib/Analysis/LoopPass.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 0b5f6266e37..e988f6444a5 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -73,30 +73,23 @@ LPPassManager::LPPassManager() CurrentLoop = nullptr; } -// Inset loop into loop nest (LoopInfo) and loop queue (LQ). -Loop &LPPassManager::addLoop(Loop *ParentLoop) { - // Create a new loop. LI will take ownership. - Loop *L = new Loop(); - - // Insert into the loop nest and the loop queue. - if (!ParentLoop) { +// Insert loop into loop nest (LoopInfo) and loop queue (LQ). +void LPPassManager::addLoop(Loop &L) { + if (!L.getParentLoop()) { // This is the top level loop. - LI->addTopLevelLoop(L); - LQ.push_front(L); - return *L; + LQ.push_front(&L); + return; } - ParentLoop->addChildLoop(L); // Insert L into the loop queue after the parent loop. for (auto I = LQ.begin(), E = LQ.end(); I != E; ++I) { - if (*I == L->getParentLoop()) { + if (*I == L.getParentLoop()) { // deque does not support insert after. ++I; - LQ.insert(I, 1, L); - break; + LQ.insert(I, 1, &L); + return; } } - return *L; } /// cloneBasicBlockSimpleAnalysis - Invoke cloneBasicBlockAnalysis hook for |