summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-05-25 03:01:31 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-05-25 03:01:31 +0000
commit29c22d2835acf876c60e90c3f527bfc1b66c152f (patch)
treee0e8ab63b55d8e48d5e81bc848967480d171517e /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
parentd5c65ffa8dd419b618b1c28602637d3e816d8a94 (diff)
downloadbcm5719-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/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnswitch.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
index 6ef1464e933..19daebd0613 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -831,7 +831,12 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,
/// mapping the blocks with the specified map.
static Loop *CloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM,
LoopInfo *LI, LPPassManager *LPM) {
- Loop &New = LPM->addLoop(PL);
+ Loop &New = *new Loop();
+ if (PL)
+ PL->addChildLoop(&New);
+ else
+ LI->addTopLevelLoop(&New);
+ LPM->addLoop(New);
// Add all of the blocks in L to the new loop.
for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
OpenPOWER on IntegriCloud