diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-28 08:30:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-28 08:30:24 +0000 |
commit | df7a33107ede974d52bd1662d9e35838a24cc130 (patch) | |
tree | 8ef756fa9d8612ab2b2752fba7cc9893cedb95b8 /lib/Core/ExecutorUtil.cpp | |
parent | 7cafc466deb29417053b6927c36e4ea29108c029 (diff) | |
download | klee-df7a33107ede974d52bd1662d9e35838a24cc130.tar.gz |
KLEE64: GetElementPtr constants should be evaluated in the target pointer width.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@77308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core/ExecutorUtil.cpp')
-rw-r--r-- | lib/Core/ExecutorUtil.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index a2cfa0ae..69bb2017 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -9,6 +9,8 @@ #include "Executor.h" +#include "Context.h" + #include "klee/Expr.h" #include "klee/Interpreter.h" #include "klee/Solver.h" @@ -75,11 +77,12 @@ namespace klee { return op1->ZExt(Expr::getWidthForLLVMType(type)); case Instruction::GetElementPtr: { - ref<ConstantExpr> base = op1; + ref<ConstantExpr> base = op1->ZExt(Context::get().getPointerWidth()); for (gep_type_iterator ii = gep_type_begin(ce), ie = gep_type_end(ce); ii != ie; ++ii) { - ref<ConstantExpr> addend = ConstantExpr::alloc(0, Expr::Int32); + ref<ConstantExpr> addend = + ConstantExpr::alloc(0, Context::get().getPointerWidth()); if (const StructType *st = dyn_cast<StructType>(*ii)) { const StructLayout *sl = kmodule->targetData->getStructLayout(st); @@ -87,7 +90,7 @@ namespace klee { addend = ConstantExpr::alloc(sl->getElementOffset((unsigned) ci->getZExtValue()), - Expr::Int32); + Context::get().getPointerWidth()); } else { const SequentialType *st = cast<SequentialType>(*ii); ref<ConstantExpr> index = @@ -95,8 +98,9 @@ namespace klee { unsigned elementSize = kmodule->targetData->getTypeStoreSize(st->getElementType()); - index = index->ZExt(Expr::Int32); - addend = index->Mul(ConstantExpr::alloc(elementSize, Expr::Int32)); + index = index->ZExt(Context::get().getPointerWidth()); + addend = index->Mul(ConstantExpr::alloc(elementSize, + Context::get().getPointerWidth())); } base = base->Add(addend); |