[llvm] r267648 - [LVI] Add a comment explaining a subtle piece of code

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 18:02:25 PDT 2016


Author: reames
Date: Tue Apr 26 20:02:25 2016
New Revision: 267648

URL: http://llvm.org/viewvc/llvm-project?rev=267648&view=rev
Log:
[LVI] Add a comment explaining a subtle piece of code

Or at least, I didn't understand the implications the first several times I read it it.


Modified:
    llvm/trunk/lib/Analysis/LazyValueInfo.cpp

Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=267648&r1=267647&r2=267648&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Apr 26 20:02:25 2016
@@ -668,27 +668,35 @@ bool LazyValueInfoCache::solveBlockValue
     return true;
   }
 
-  // If this value is a nonnull pointer, record it's range and bailout.
+  // If this value is a nonnull pointer, record it's range and bailout.  Note
+  // that for all other pointer typed values, we terminate the search at the
+  // definition.  We could easily extend this to look through geps, bitcasts,
+  // and the like to prove non-nullness, but it's not clear that's worth it
+  // compile time wise.  The context-insensative value walk done inside
+  // isKnownNonNull gets most of the profitable cases at much less expense.
+  // This does mean that we have a sensativity to where the defining
+  // instruction is placed, even if it could legally be hoisted much higher.
+  // That is unfortunate.
   PointerType *PT = dyn_cast<PointerType>(BBI->getType());
   if (PT && isKnownNonNull(BBI)) {
     Res = LVILatticeVal::getNot(ConstantPointerNull::get(PT));
     insertResult(Val, BB, Res);
     return true;
   }
-
-  if (isa<CastInst>(BBI) && BBI->getType()->isIntegerTy()) {
-    if (!solveBlockValueCast(Res, BBI, BB))
-      return false;
-    insertResult(Val, BB, Res);
-    return true;
-  }
-
-  BinaryOperator *BO = dyn_cast<BinaryOperator>(BBI);
-  if (BO && isa<ConstantInt>(BO->getOperand(1))) { 
-    if (!solveBlockValueBinaryOp(Res, BBI, BB))
-      return false;
-    insertResult(Val, BB, Res);
-    return true;
+  else if (BBI->getType()->isIntegerTy()) {
+    if (isa<CastInst>(BBI)) {
+      if (!solveBlockValueCast(Res, BBI, BB))
+        return false;
+      insertResult(Val, BB, Res);
+      return true;
+    }
+    BinaryOperator *BO = dyn_cast<BinaryOperator>(BBI);
+    if (BO && isa<ConstantInt>(BO->getOperand(1))) { 
+      if (!solveBlockValueBinaryOp(Res, BBI, BB))
+        return false;
+      insertResult(Val, BB, Res);
+      return true;
+    }
   }
 
   DEBUG(dbgs() << " compute BB '" << BB->getName()




More information about the llvm-commits mailing list