diff options
author | Daniel Jasper <djasper@google.com> | 2016-12-19 08:22:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-12-19 08:22:17 +0000 |
commit | aec2fa352f533d230ab50b6c3002a1a664c9d6c2 (patch) | |
tree | 21fa530583cde5282092391e6891d959208f28d9 /llvm/lib/Analysis/Lint.cpp | |
parent | e5f3eba9c31f4d00c73f4714df52ffced4532927 (diff) | |
download | llvm-aec2fa352f533d230ab50b6c3002a1a664c9d6c2.zip llvm-aec2fa352f533d230ab50b6c3002a1a664c9d6c2.tar.gz llvm-aec2fa352f533d230ab50b6c3002a1a664c9d6c2.tar.bz2 |
Revert @llvm.assume with operator bundles (r289755-r289757)
This creates non-linear behavior in the inliner (see more details in
r289755's commit thread).
llvm-svn: 290086
Diffstat (limited to 'llvm/lib/Analysis/Lint.cpp')
-rw-r--r-- | llvm/lib/Analysis/Lint.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index 75d03d1..2ca46b1 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -40,6 +40,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Twine.h" #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/Loads.h" @@ -127,6 +128,7 @@ namespace { Module *Mod; const DataLayout *DL; AliasAnalysis *AA; + AssumptionCache *AC; DominatorTree *DT; TargetLibraryInfo *TLI; @@ -143,6 +145,7 @@ namespace { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); AU.addRequired<AAResultsWrapperPass>(); + AU.addRequired<AssumptionCacheTracker>(); AU.addRequired<TargetLibraryInfoWrapperPass>(); AU.addRequired<DominatorTreeWrapperPass>(); } @@ -182,6 +185,7 @@ namespace { char Lint::ID = 0; INITIALIZE_PASS_BEGIN(Lint, "lint", "Statically lint-checks LLVM IR", false, true) +INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) @@ -199,6 +203,7 @@ bool Lint::runOnFunction(Function &F) { Mod = F.getParent(); DL = &F.getParent()->getDataLayout(); AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); + AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F); DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(); visit(F); @@ -520,7 +525,8 @@ void Lint::visitShl(BinaryOperator &I) { "Undefined result: Shift count out of range", &I); } -static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT) { +static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, + AssumptionCache *AC) { // Assume undef could be zero. if (isa<UndefValue>(V)) return true; @@ -529,7 +535,7 @@ static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT) { if (!VecTy) { unsigned BitWidth = V->getType()->getIntegerBitWidth(); APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); - computeKnownBits(V, KnownZero, KnownOne, DL, 0, + computeKnownBits(V, KnownZero, KnownOne, DL, 0, AC, dyn_cast<Instruction>(V), DT); return KnownZero.isAllOnesValue(); } @@ -560,22 +566,22 @@ static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT) { } void Lint::visitSDiv(BinaryOperator &I) { - Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT), + Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC), "Undefined behavior: Division by zero", &I); } void Lint::visitUDiv(BinaryOperator &I) { - Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT), + Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC), "Undefined behavior: Division by zero", &I); } void Lint::visitSRem(BinaryOperator &I) { - Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT), + Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC), "Undefined behavior: Division by zero", &I); } void Lint::visitURem(BinaryOperator &I) { - Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT), + Assert(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC), "Undefined behavior: Division by zero", &I); } @@ -693,7 +699,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk, // As a last resort, try SimplifyInstruction or constant folding. if (Instruction *Inst = dyn_cast<Instruction>(V)) { - if (Value *W = SimplifyInstruction(Inst, *DL, TLI, DT)) + if (Value *W = SimplifyInstruction(Inst, *DL, TLI, DT, AC)) return findValueImpl(W, OffsetOk, Visited); } else if (auto *C = dyn_cast<Constant>(V)) { if (Value *W = ConstantFoldConstant(C, *DL, TLI)) |