[PATCH] D64533: [IndVars] Special case the problematic (gep inbounds p, iv == nullptr) problem (pr42357)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 13 13:41:00 PDT 2019


nikic added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:206
+        L->isLoopInvariant(GEP->getPointerOperand()) &&
+        GEP->getType()->isPointerTy()) {
+      IRBuilder<> B(ICmp);
----------------
`GEP->getType()->isPointerTy()` should always be true for a single-index GEP ... right?


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:220
+      // whereas p + NegNum == nullptr would imply p is out of bounds
+      if (SE->isKnownNonZero(Idx)) {
+        if (Pred == ICmpInst::ICMP_NE)
----------------
I believe we also need to check for a pointer to a zero-sized type here, in which case we might have `null + 0*Idx == null` even if the index is non-zero.


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

https://reviews.llvm.org/D64533





More information about the llvm-commits mailing list