ValueTracking: Make computeKnownBits for Arguments a little more clear
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 3 Jan 2015 02:33:25 +0000 (02:33 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 3 Jan 2015 02:33:25 +0000 (02:33 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225109 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index 3a0efa76b2f300d5e061c0c3fd4b34da55817fc6..6fdf4afebc2bf97f0958d837f5daf17433cb45cc 100644 (file)
@@ -831,6 +831,9 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
 
     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...