diff options
| author | Xin Tong <trent.xin.tong@gmail.com> | 2017-01-15 21:17:52 +0000 |
|---|---|---|
| committer | Xin Tong <trent.xin.tong@gmail.com> | 2017-01-15 21:17:52 +0000 |
| commit | ca02360f4660d5e51b455e199e64416ef68408f3 (patch) | |
| tree | 63bc92f9e13a8c2837d9147ead1264fdfeb068a0 /llvm/lib/Analysis | |
| parent | 6ed996cdf02a1ba6f35cd9b207b66165c71fa9e1 (diff) | |
| download | bcm5719-llvm-ca02360f4660d5e51b455e199e64416ef68408f3.tar.gz bcm5719-llvm-ca02360f4660d5e51b455e199e64416ef68408f3.zip | |
Use getLoopLatch in place of isLoopSimplifyForm
Summary:
Use getLoopLatch in place of isLoopSimplifyForm. we do not need
to know whether the loop has a preheader nor dedicated exits.
Reviewers: hfinkel, sanjoy, atrick, mkuper
Subscribers: mzolotukhin, llvm-commits
Differential Revision: https://reviews.llvm.org/D28724
llvm-svn: 292078
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 714e0d5173f..e7e7612a66d 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -211,9 +211,11 @@ bool Loop::isSafeToClone() const { MDNode *Loop::getLoopID() const { MDNode *LoopID = nullptr; - if (isLoopSimplifyForm()) { - LoopID = getLoopLatch()->getTerminator()->getMetadata(LLVMContext::MD_loop); + if (BasicBlock *Latch = getLoopLatch()) { + LoopID = Latch->getTerminator()->getMetadata(LLVMContext::MD_loop); } else { + assert(!getLoopLatch() && + "The loop should have no single latch at this point"); // Go through each predecessor of the loop header and check the // terminator for the metadata. BasicBlock *H = getHeader(); @@ -248,11 +250,12 @@ void Loop::setLoopID(MDNode *LoopID) const { assert(LoopID->getNumOperands() > 0 && "Loop ID needs at least one operand"); assert(LoopID->getOperand(0) == LoopID && "Loop ID should refer to itself"); - if (isLoopSimplifyForm()) { - getLoopLatch()->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID); + if (BasicBlock *Latch = getLoopLatch()) { + Latch->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID); return; } + assert(!getLoopLatch() && "The loop should have no single latch at this point"); BasicBlock *H = getHeader(); for (BasicBlock *BB : this->blocks()) { TerminatorInst *TI = BB->getTerminator(); |

