[llvm] r225109 - ValueTracking: Make computeKnownBits for Arguments a little more clear

David Majnemer david.majnemer at gmail.com
Fri Jan 2 18:33:25 PST 2015


Author: majnemer
Date: Fri Jan  2 20:33:25 2015
New Revision: 225109

URL: http://llvm.org/viewvc/llvm-project?rev=225109&view=rev
Log:
ValueTracking: Make computeKnownBits for Arguments a little more clear

We would sometimes leave the out-param APInts untouched while going
through computeKnownBits.  While I don't know of a way to trigger a bug
involving this in practice, it goes against the overall design of
computeKnownBits.

Found via code inspection.

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

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=225109&r1=225108&r2=225109&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Jan  2 20:33:25 2015
@@ -831,6 +831,9 @@ void computeKnownBits(Value *V, APInt &K
 
     if (Align)
       KnownZero = APInt::getLowBitsSet(BitWidth, countTrailingZeros(Align));
+    else
+      KnownZero.clearAllBits();
+    KnownOne.clearAllBits();
 
     // Don't give up yet... there might be an assumption that provides more
     // information...





More information about the llvm-commits mailing list