summaryrefslogtreecommitdiff
path: root/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-08-24 07:55:44 +0000
committerOwen Anderson <resistor@mac.com>2010-08-24 07:55:44 +0000
commit59b06dc7758fb6087cdcf5d9f45a9ebb11e05504 (patch)
tree37253b972383812482a242e895070025d269110d /lib/Analysis/LazyValueInfo.cpp
parentd01347e0808f1d06b92d04bd9c0798df0d024879 (diff)
downloadllvm-59b06dc7758fb6087cdcf5d9f45a9ebb11e05504.tar.gz
llvm-59b06dc7758fb6087cdcf5d9f45a9ebb11e05504.tar.bz2
llvm-59b06dc7758fb6087cdcf5d9f45a9ebb11e05504.tar.xz
Don't assume that all constants with integer types are ConstantInts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--lib/Analysis/LazyValueInfo.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index 57b4dcb8d7..e8cc69de55 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -216,6 +216,8 @@ public:
return markOverdefined();
else
return markConstantRange(NewR);
+ } else if (!isUndefined()) {
+ return markOverdefined();
}
assert(isUndefined() && "Unexpected lattice");
@@ -541,7 +543,12 @@ LVILatticeVal LVIQuery::getBlockValue(BasicBlock *BB) {
ConstantRange RHSRange(1);
const IntegerType *ResultTy = cast<IntegerType>(BBI->getType());
if (isa<BinaryOperator>(BBI)) {
- RHS = cast<ConstantInt>(BBI->getOperand(1));
+ RHS = dyn_cast<ConstantInt>(BBI->getOperand(1));
+ if (!RHS) {
+ Result.markOverdefined();
+ return Result;
+ }
+
RHSRange = ConstantRange(RHS->getValue(), RHS->getValue()+1);
}
@@ -842,7 +849,9 @@ LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
}
if (Result.isConstantRange()) {
- ConstantInt *CI = cast<ConstantInt>(C);
+ ConstantInt *CI = dyn_cast<ConstantInt>(C);
+ if (!CI) return Unknown;
+
ConstantRange CR = Result.getConstantRange();
if (Pred == ICmpInst::ICMP_EQ) {
if (!CR.contains(CI->getValue()))