[PATCH] D66084: Remove asserts in getLoopGuardBranch

Dangeti Tharun kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 23:01:59 PDT 2019


DTharun updated this revision to Diff 214765.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66084/new/

https://reviews.llvm.org/D66084

Files:
  lib/Analysis/LoopInfo.cpp


Index: lib/Analysis/LoopInfo.cpp
===================================================================
--- lib/Analysis/LoopInfo.cpp
+++ lib/Analysis/LoopInfo.cpp
@@ -360,12 +360,16 @@
 }
 
 BranchInst *Loop::getLoopGuardBranch() const {
-  assert(isLoopSimplifyForm() && "Only valid for loop in simplify form");
+  if (!isLoopSimplifyForm())
+    return nullptr;
+
   BasicBlock *Preheader = getLoopPreheader();
   BasicBlock *Latch = getLoopLatch();
-  assert(Preheader && Latch &&
-         "Expecting a loop with valid preheader and latch");
-  assert(isLoopExiting(Latch) && "Only valid for rotated loop");
+
+  // Expecting a loop with valid preheader and latch,
+  // and loop should be in rotate form.
+  if (!Preheader || !Latch || !isLoopExiting(Latch))
+    return nullptr;
 
   Instruction *LatchTI = Latch->getTerminator();
   if (!LatchTI || LatchTI->getNumSuccessors() != 2)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66084.214765.patch
Type: text/x-patch
Size: 888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190813/4b24011c/attachment.bin>


More information about the llvm-commits mailing list