diff options
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 1dc63a3c333..dbab5db7dbc 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -360,11 +360,17 @@ bool Loop::isAuxiliaryInductionVariable(PHINode &AuxIndVar, } BranchInst *Loop::getLoopGuardBranch() const { - assert(isLoopSimplifyForm() && "Only valid for loop in simplify form"); + if (!isLoopSimplifyForm()) + return nullptr; + BasicBlock *Preheader = getLoopPreheader(); - assert(Preheader && getLoopLatch() && + BasicBlock *Latch = getLoopLatch(); + assert(Preheader && Latch && "Expecting a loop with valid preheader and latch"); - assert(isLoopExiting(getLoopLatch()) && "Only valid for rotated loop"); + + // Loop should be in rotate form. + if (!isLoopExiting(Latch)) + return nullptr; // Disallow loops with more than one unique exit block, as we do not verify // that GuardOtherSucc post dominates all exit blocks. |