summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorWhitney Tsang <whitney.uwaterloo@gmail.com>2019-10-06 16:39:43 +0000
committerWhitney Tsang <whitney.uwaterloo@gmail.com>2019-10-06 16:39:43 +0000
commitdcb75bf843eae4a7f0d6d72930f49f7d31c07f98 (patch)
tree19b684f6591d1a7b108cea38fd93931f26249fce /llvm/lib/Analysis/LoopInfo.cpp
parentde0e3aac2a27496545f809f2dffac48b5ab7f594 (diff)
downloadbcm5719-llvm-dcb75bf843eae4a7f0d6d72930f49f7d31c07f98.tar.gz
bcm5719-llvm-dcb75bf843eae4a7f0d6d72930f49f7d31c07f98.zip
[LOOPGUARD] Remove asserts in getLoopGuardBranch
Summary: The assertion in getLoopGuardBranch can be a 'return nullptr' under if condition. Authored By: DTharun Reviewer: Whitney, fhahn Reviewed By: Whitney, fhahn Subscribers: fhahn, llvm-commits Tag: LLVM Differential Revision: https://reviews.llvm.org/D66084 llvm-svn: 373857
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp12
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.
OpenPOWER on IntegriCloud