[llvm] r311400 - [ValueTracking] Add assertions that the starting Depth in isKnownToBeAPowerOfTwo and ComputeNumSignBitsImpl is not above MaxDepth
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 15:56:12 PDT 2017
Author: ctopper
Date: Mon Aug 21 15:56:12 2017
New Revision: 311400
URL: http://llvm.org/viewvc/llvm-project?rev=311400&view=rev
Log:
[ValueTracking] Add assertions that the starting Depth in isKnownToBeAPowerOfTwo and ComputeNumSignBitsImpl is not above MaxDepth
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.
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=311400&r1=311399&r2=311400&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Aug 21 15:56:12 2017
@@ -1562,6 +1562,8 @@ void computeKnownBits(const Value *V, Kn
/// 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
/// 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
More information about the llvm-commits
mailing list