From 62029881a52097477a3a6720691a5dedc17ad36e Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 28 Jul 2009 08:39:29 +0000 Subject: 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 --- lib/Core/Executor.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/Core/Executor.cpp') 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(KI); - ref constantOffset = ConstantExpr::alloc(0, Expr::Int32); + ref 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(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(*ii); unsigned elementSize = kmodule->targetData->getTypeStoreSize(st->getElementType()); Value *operand = ii.getOperand(); if (Constant *c = dyn_cast(operand)) { - ref index = evalConstant(c); - ref addend = MulExpr::create(Expr::createCoerceToPointerType(index), - Expr::createPointer(elementSize)); - constantOffset = constantOffset->Add(cast(addend)); + ref index = + evalConstant(c)->ZExt(Context::get().getPointerWidth()); + ref addend = + index->Mul(ConstantExpr::alloc(elementSize, + Context::get().getPointerWidth())); + constantOffset = constantOffset->Add(addend); } else { kgepi->indices.push_back(std::make_pair(index, elementSize)); } -- cgit 1.4.1