diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-08 14:50:01 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-08 14:50:01 +0000 |
commit | 9fd02a71a39b8e923e3a2ede6b9640871d503e2b (patch) | |
tree | 6e9767b686b3d87950fd279126075275c29cbae3 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 4964e3837e406e6375488fd9ecad82bea2a1881b (diff) | |
download | bcm5719-llvm-9fd02a71a39b8e923e3a2ede6b9640871d503e2b.tar.gz bcm5719-llvm-9fd02a71a39b8e923e3a2ede6b9640871d503e2b.zip |
Revert "[ValueTracking] Improve isKnowNonZero for Ints"
This reverts commit 3b137a495686bd6018d115ea82fb8bb7718349fd.
As reported in https://reviews.llvm.org/D60846, this is causing
miscompiles.
llvm-svn: 360260
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 839f539707a..54575441b71 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1893,9 +1893,10 @@ static bool isGEPKnownNonNull(const GEPOperator *GEP, unsigned Depth, return false; } -static bool isKnownNonZeroFromDominatingCondition(const Value *V, +static bool isKnownNonNullFromDominatingCondition(const Value *V, const Instruction *CtxI, const DominatorTree *DT) { + assert(V->getType()->isPointerTy() && "V must be pointer type"); assert(!isa<ConstantData>(V) && "Did not expect ConstantPointerNull"); if (!CtxI || !DT) @@ -1908,15 +1909,14 @@ static bool isKnownNonZeroFromDominatingCondition(const Value *V, break; NumUsesExplored++; - // If the value is a pointer and used as an argument to a call or invoke, - // then argument attributes may provide an answer about null-ness. - if (V->getType()->isPointerTy()) - if (auto CS = ImmutableCallSite(U)) - if (auto *CalledFunc = CS.getCalledFunction()) - for (const Argument &Arg : CalledFunc->args()) - if (CS.getArgOperand(Arg.getArgNo()) == V && - Arg.hasNonNullAttr() && DT->dominates(CS.getInstruction(), CtxI)) - return true; + // If the value is used as an argument to a call or invoke, then argument + // attributes may provide an answer about null-ness. + if (auto CS = ImmutableCallSite(U)) + if (auto *CalledFunc = CS.getCalledFunction()) + for (const Argument &Arg : CalledFunc->args()) + if (CS.getArgOperand(Arg.getArgNo()) == V && + Arg.hasNonNullAttr() && DT->dominates(CS.getInstruction(), CtxI)) + return true; // Consider only compare instructions uniquely controlling a branch CmpInst::Predicate Pred; @@ -2064,11 +2064,11 @@ bool isKnownNonZero(const Value *V, unsigned Depth, const Query &Q) { } - if (isKnownNonZeroFromDominatingCondition(V, Q.CxtI, Q.DT)) - return true; - // Check for recursive pointer simplifications. if (V->getType()->isPointerTy()) { + if (isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT)) + return true; + // Look through bitcast operations, GEPs, and int2ptr instructions as they // do not alter the value, or at least not the nullness property of the // value, e.g., int2ptr is allowed to zero/sign extend the value. |