]> granicus.if.org Git - llvm/commitdiff
[ValueTracking] Add assertions that the starting Depth in isKnownToBeAPowerOfTwo...
authorCraig Topper <craig.topper@intel.com>
Mon, 21 Aug 2017 22:56:12 +0000 (22:56 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 21 Aug 2017 22:56:12 +0000 (22:56 +0000)
The function does an equality check later to terminate the recursion, but that won't work if its starts out too high. Similar assert already exists in computeKnownBits.

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

lib/Analysis/ValueTracking.cpp

index d936c48a3a67802011383b79fe2eba81c5eb4e78..4bf17b1502b926207c2c433a95bc92dd064b3337 100644 (file)
@@ -1562,6 +1562,8 @@ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
 /// types and vectors of integers.
 bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
                             const Query &Q) {
+  assert(Depth <= MaxDepth && "Limit Search Depth");
+
   if (const Constant *C = dyn_cast<Constant>(V)) {
     if (C->isNullValue())
       return OrZero;
@@ -2021,6 +2023,7 @@ static unsigned ComputeNumSignBits(const Value *V, unsigned Depth,
 /// vector element with the mininum number of known sign bits.
 static unsigned ComputeNumSignBitsImpl(const Value *V, unsigned Depth,
                                        const Query &Q) {
+  assert(Depth <= MaxDepth && "Limit Search Depth");
 
   // We return the minimum number of sign bits that are guaranteed to be present
   // in V, so for undef we have to conservatively return 1.  We don't have the