[PATCH] D66084: Remove asserts in getLoopGuardBranch

Dangeti Tharun kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 00:49:35 PDT 2019


DTharun updated this revision to Diff 219851.
DTharun edited the summary of this revision.
DTharun added a comment.

No test cases fail from LoopInfoTest.cpp.


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,18 @@
 }

 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");
+
+  // Loop should be in rotate form.
+  if (!isLoopExiting(Latch))
+    return nullptr;

   Instruction *LatchTI = Latch->getTerminator();
   if (!LatchTI || LatchTI->getNumSuccessors() != 2)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66084.219851.patch
Type: text/x-patch
Size: 805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190912/43c92bdf/attachment.bin>


More information about the llvm-commits mailing list