aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-03-04 22:27:39 +0000
committerPhilip Reames <listmail@philipreames.com>2016-03-04 22:27:39 +0000
commita0c9f6e73622e7f040d827850acbdfcbde945998 (patch)
tree351e3d2ba308dc5a7bb8b764ac377ec7e341f571 /llvm/lib/Analysis/LazyValueInfo.cpp
parentecdc98fdaea83d9d4750d93316ba1b2b277d1c51 (diff)
downloadllvm-a0c9f6e73622e7f040d827850acbdfcbde945998.zip
llvm-a0c9f6e73622e7f040d827850acbdfcbde945998.tar.gz
llvm-a0c9f6e73622e7f040d827850acbdfcbde945998.tar.bz2
[LVI] Fix a bug which prevented use of !range metadata within a query
The diff is relatively large since I took a chance to rearrange the code I had to touch in a more obvious way, but the key bit is merely using the !range metadata when we can't analyze the instruction further. The previous !range metadata code was essentially just dead since no binary operator or cast will have !range metadata (per Verifier) and it was otherwise dropped on the floor. llvm-svn: 262751
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index b2ce163..467f464 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -669,36 +669,24 @@ bool LazyValueInfoCache::solveBlockValue(Value *Val, BasicBlock *BB) {
return true;
}
- // If this is an instruction which supports range metadata, intersect the
- // implied range.
- Res = intersect(Res, getFromRangeMetadata(BBI));
-
- // We can only analyze the definitions of certain classes of instructions
- // (integral binops and casts at the moment), so bail if this isn't one.
- LVILatticeVal Result;
- if ((!isa<BinaryOperator>(BBI) && !isa<CastInst>(BBI)) ||
- !BBI->getType()->isIntegerTy()) {
- DEBUG(dbgs() << " compute BB '" << BB->getName()
- << "' - overdefined because inst def found.\n");
- Res.markOverdefined();
+ if (isa<CastInst>(BBI) && BBI->getType()->isIntegerTy()) {
+ if (!solveBlockValueConstantRange(Res, BBI, BB))
+ return false;
insertResult(Val, BB, Res);
return true;
}
- // FIXME: We're currently limited to binops with a constant RHS. This should
- // be improved.
BinaryOperator *BO = dyn_cast<BinaryOperator>(BBI);
- if (BO && !isa<ConstantInt>(BO->getOperand(1))) {
- DEBUG(dbgs() << " compute BB '" << BB->getName()
- << "' - overdefined because inst def found.\n");
-
- Res.markOverdefined();
+ if (BO && isa<ConstantInt>(BO->getOperand(1))) {
+ if (!solveBlockValueConstantRange(Res, BBI, BB))
+ return false;
insertResult(Val, BB, Res);
return true;
}
- if (!solveBlockValueConstantRange(Res, BBI, BB))
- return false;
+ DEBUG(dbgs() << " compute BB '" << BB->getName()
+ << "' - unknown inst def found.\n");
+ Res = getFromRangeMetadata(BBI);
insertResult(Val, BB, Res);
return true;
}
@@ -1007,7 +995,7 @@ bool LazyValueInfoCache::solveBlockValueSelect(LVILatticeVal &BBLV,
bool LazyValueInfoCache::solveBlockValueConstantRange(LVILatticeVal &BBLV,
Instruction *BBI,
- BasicBlock *BB) {
+ BasicBlock *BB) {
// Figure out the range of the LHS. If that fails, bail.
if (!hasBlockValue(BBI->getOperand(0), BB)) {
if (pushBlockValue(std::make_pair(BB, BBI->getOperand(0))))