From df7a33107ede974d52bd1662d9e35838a24cc130 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 28 Jul 2009 08:30:24 +0000 Subject: 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 --- lib/Core/ExecutorUtil.cpp | 14 +++++++++----- 1 file 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 base = op1; + ref base = op1->ZExt(Context::get().getPointerWidth()); for (gep_type_iterator ii = gep_type_begin(ce), ie = gep_type_end(ce); ii != ie; ++ii) { - ref addend = ConstantExpr::alloc(0, Expr::Int32); + ref addend = + ConstantExpr::alloc(0, Context::get().getPointerWidth()); if (const StructType *st = dyn_cast(*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(*ii); ref 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); -- cgit 1.4.1