diff options
author | Whitney Tsang <whitneyt@ca.ibm.com> | 2019-12-17 00:03:04 +0000 |
---|---|---|
committer | Whitney Tsang <whitneyt@ca.ibm.com> | 2019-12-17 01:06:14 +0000 |
commit | c066ff11d84a7797503ad5a44c4129136926dc85 (patch) | |
tree | 173a2006dc9e741ecfa2ffaacfb8c7e582ff3474 /llvm/lib/Transforms/Utils | |
parent | d6777207b4fd4868a4409cc39936156ec3aa3c50 (diff) | |
download | bcm5719-llvm-c066ff11d84a7797503ad5a44c4129136926dc85.tar.gz bcm5719-llvm-c066ff11d84a7797503ad5a44c4129136926dc85.zip |
[LoopUtils] Updated deleteDeadLoop() to handle loop nest.
Reviewer: kariddi, sanjoy, reames, Meinersbur, bmahjour, etiotto,
kbarton
Reviewed By: Meinersbur
Subscribers: mgorny, hiraditya, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D70939
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 68ef0fe4071..2340e8c72e1 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -673,7 +673,18 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT = nullptr, LI->removeBlock(BB); // The last step is to update LoopInfo now that we've eliminated this loop. - LI->erase(L); + // Note: LoopInfo::erase remove the given loop and relink its subloops with + // its parent. While removeLoop/removeChildLoop remove the given loop but + // not relink its subloops, which is what we want. + if (Loop *ParentLoop = L->getParentLoop()) { + Loop::iterator I = find(ParentLoop->begin(), ParentLoop->end(), L); + assert(I != ParentLoop->end() && "Couldn't find loop"); + ParentLoop->removeChildLoop(I); + } else { + Loop::iterator I = find(LI->begin(), LI->end(), L); + assert(I != LI->end() && "Couldn't find loop"); + LI->removeLoop(I); + } } } |