aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-28 08:39:29 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-28 08:39:29 +0000
commit62029881a52097477a3a6720691a5dedc17ad36e (patch)
treeeccf5d8b769690191a7929d1c0f92ad901833ca8 /lib/Core
parenteeb204f466cb51143d7371ea0847df1eaa8f77c2 (diff)
downloadklee-62029881a52097477a3a6720691a5dedc17ad36e.tar.gz
KLEE64: When binding GetElementPtr constants, do evaluation in pointer width of
target. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@77310 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 0e2f7a8c..a8056b8b 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -2142,7 +2142,8 @@ void Executor::bindInstructionConstants(KInstruction *KI) {
return;
KGEPInstruction *kgepi = static_cast<KGEPInstruction*>(KI);
- ref<ConstantExpr> constantOffset = ConstantExpr::alloc(0, Expr::Int32);
+ ref<ConstantExpr> constantOffset =
+ ConstantExpr::alloc(0, Context::get().getPointerWidth());
unsigned index = 1;
for (gep_type_iterator ii = gep_type_begin(gepi), ie = gep_type_end(gepi);
ii != ie; ++ii) {
@@ -2151,17 +2152,19 @@ void Executor::bindInstructionConstants(KInstruction *KI) {
const ConstantInt *ci = cast<ConstantInt>(ii.getOperand());
uint64_t addend = sl->getElementOffset((unsigned) ci->getZExtValue());
constantOffset = constantOffset->Add(ConstantExpr::alloc(addend,
- Expr::Int32));
+ Context::get().getPointerWidth()));
} else {
const SequentialType *st = cast<SequentialType>(*ii);
unsigned elementSize =
kmodule->targetData->getTypeStoreSize(st->getElementType());
Value *operand = ii.getOperand();
if (Constant *c = dyn_cast<Constant>(operand)) {
- ref<Expr> index = evalConstant(c);
- ref<Expr> addend = MulExpr::create(Expr::createCoerceToPointerType(index),
- Expr::createPointer(elementSize));
- constantOffset = constantOffset->Add(cast<ConstantExpr>(addend));
+ ref<ConstantExpr> index =
+ evalConstant(c)->ZExt(Context::get().getPointerWidth());
+ ref<ConstantExpr> addend =
+ index->Mul(ConstantExpr::alloc(elementSize,
+ Context::get().getPointerWidth()));
+ constantOffset = constantOffset->Add(addend);
} else {
kgepi->indices.push_back(std::make_pair(index, elementSize));
}