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

Whitney via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 13:55:12 PDT 2019


Whitney 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;
----------------
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.


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