[llvm-commits] [PATCH] Add support to ValueTracking for determining that a pointer is non-null by virtue of inbounds GEPs that preclude a null pointer.

Duncan Sands baldrick at free.fr
Thu Dec 6 03:12:43 PST 2012



================
Comment at: lib/Analysis/ValueTracking.cpp:892-894
@@ +891,5 @@
+    // reason about the GEP.
+    if ((!OpC && !isKnownNonZero(GTI.getOperand(), DL, Depth++)) ||
+        (OpC && OpC->isZero()))
+      continue;
+
----------------
You could just always test isKnownNonZero rather than specially handling the constant case (as isKnownNonZero knows about constants) and leave mucking about with constants to the logic for struct types.  That would get rid of all the OpC vs !OpC madness.  With the simplest implementation this would mean that you wouldn't catch the constant case if Depth was already maximal, but do we care?


http://llvm-reviews.chandlerc.com/D160

BRANCH
  master

ARCANIST PROJECT
  llvm



More information about the llvm-commits mailing list