summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 4664c78b8c0..07f72addc81 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -213,26 +213,21 @@ bool Loop::isSafeToClone() const {
MDNode *Loop::getLoopID() const {
MDNode *LoopID = nullptr;
- 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 the latch blocks and check the terminator for the metadata.
- SmallVector<BasicBlock *, 4> LatchesBlocks;
- getLoopLatches(LatchesBlocks);
- for (BasicBlock *BB : LatchesBlocks) {
- TerminatorInst *TI = BB->getTerminator();
- MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
-
- if (!MD)
- return nullptr;
-
- if (!LoopID)
- LoopID = MD;
- else if (MD != LoopID)
- return nullptr;
- }
+
+ // Go through the latch blocks and check the terminator for the metadata.
+ SmallVector<BasicBlock *, 4> LatchesBlocks;
+ getLoopLatches(LatchesBlocks);
+ for (BasicBlock *BB : LatchesBlocks) {
+ TerminatorInst *TI = BB->getTerminator();
+ MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
+
+ if (!MD)
+ return nullptr;
+
+ if (!LoopID)
+ LoopID = MD;
+ else if (MD != LoopID)
+ return nullptr;
}
if (!LoopID || LoopID->getNumOperands() == 0 ||
LoopID->getOperand(0) != LoopID)
OpenPOWER on IntegriCloud