[PATCH] D16240: [InstCombine] Simplify a known nonzero incoming value of PHI

Jun Bum Lim via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 22 10:38:48 PST 2016


junbuml added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:940
@@ +939,3 @@
+        BasicBlock *InBB = PN.getIncomingBlock(i);
+        Instruction *CtxI = (InBB && InBB->getTerminator())
+                                ? (Instruction *)InBB->getTerminator()
----------------
sanjoy wrote:
> I think `InBB` will always be non-null and have a terminator in a valid CFG.  Have you seen otherwise?
I haven't seen any null terminator in my environment. But, getTerminator() possibly returns nullptr. Since I cannot guarantee non-null terminator in all situations I'd rather keep the null check.

  TerminatorInst *BasicBlock::getTerminator() {
    if (InstList.empty()) return nullptr;
    return dyn_cast<TerminatorInst>(&InstList.back());
  }


http://reviews.llvm.org/D16240





More information about the llvm-commits mailing list