diff options
Diffstat (limited to 'lib/Core')
-rw-r--r-- | lib/Core/Context.cpp | 6 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/Core/Context.cpp b/lib/Core/Context.cpp index 45dbdca0..979970aa 100644 --- a/lib/Core/Context.cpp +++ b/lib/Core/Context.cpp @@ -35,7 +35,11 @@ const Context &Context::get() { // FIXME: This is a total hack, just to avoid a layering issue until this stuff // moves out of Expr. -ref<Expr> Expr::createCoerceToPointerType(ref<Expr> e) { +ref<Expr> Expr::createSExtToPointerWidth(ref<Expr> e) { + return SExtExpr::create(e, Context::get().getPointerWidth()); +} + +ref<Expr> Expr::createZExtToPointerWidth(ref<Expr> e) { return ZExtExpr::create(e, Context::get().getPointerWidth()); } diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 48a8b57a..1a37498f 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -1863,7 +1863,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { ref<Expr> size = Expr::createPointer(elementSize); if (ai->isArrayAllocation()) { ref<Expr> count = eval(ki, 0, state).value; - count = Expr::createCoerceToPointerType(count); + count = Expr::createZExtToPointerWidth(count); size = MulExpr::create(size, count); } bool isLocal = i->getOpcode()==Instruction::Alloca; @@ -1899,7 +1899,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { uint64_t elementSize = it->second; ref<Expr> index = eval(ki, it->first, state).value; base = AddExpr::create(base, - MulExpr::create(Expr::createCoerceToPointerType(index), + MulExpr::create(Expr::createSExtToPointerWidth(index), Expr::createPointer(elementSize))); } if (kgepi->offset) @@ -2320,7 +2320,7 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) { Value *operand = ii.getOperand(); if (Constant *c = dyn_cast<Constant>(operand)) { ref<ConstantExpr> index = - evalConstant(c)->ZExt(Context::get().getPointerWidth()); + evalConstant(c)->SExt(Context::get().getPointerWidth()); ref<ConstantExpr> addend = index->Mul(ConstantExpr::alloc(elementSize, Context::get().getPointerWidth())); |