[PATCH] D63885: [LOOPINFO] Introduce the loop guard API.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 16:22:39 PDT 2019


reames added inline comments.


================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:386
+  BranchInst *GuardBI = dyn_cast_or_null<BranchInst>(GuardBB->getTerminator());
+  if (!GuardBI || GuardBI->getNumSuccessors() != 2)
+    return nullptr;
----------------
Whitney wrote:
> reames wrote:
> > Branches only have 2 successors, so remove that check.
> > And replace the dyn_cast_or_null with a dyn_cast.  getTerminator can never return null on properly constructed IR.  
> A branch instruction can have 1 successor if it is not conditional. This function is a utility function, so it can be called anywhere, which include basic block in the middle of construction, so it is possible that getTerminator return nullptr.
It's idiomatic to use isConditional for the former, and no to the later.  Utilities assume well constructed IR unless there is a dang good motivating example not to.  Please fix.  


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63885





More information about the llvm-commits mailing list