diff options
Diffstat (limited to 'lib/Core/Executor.cpp')
-rw-r--r-- | lib/Core/Executor.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 1da91f2a..b12caec0 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -940,7 +940,7 @@ ref<klee::ConstantExpr> Executor::evalConstant(Constant *c) { } else if (isa<ConstantPointerNull>(c)) { return Expr::createPointer(0); } else if (isa<UndefValue>(c)) { - return ConstantExpr::create(0, Expr::getWidthForLLVMType(c->getType())); + return ConstantExpr::create(0, getWidthForLLVMType(c->getType())); } else { // Constant{AggregateZero,Array,Struct,Vector} assert(0 && "invalid argument to evalConstant()"); @@ -1355,7 +1355,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { if (t != Type::getVoidTy(getGlobalContext())) { // may need to do coercion due to bitcasts Expr::Width from = result->getWidth(); - Expr::Width to = Expr::getWidthForLLVMType(t); + Expr::Width to = getWidthForLLVMType(t); if (from != to) { CallSite cs = (isa<InvokeInst>(caller) ? CallSite(cast<InvokeInst>(caller)) : @@ -1547,7 +1547,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { Expr::Width to, from = (*ai)->getWidth(); if (i<fType->getNumParams()) { - to = Expr::getWidthForLLVMType(fType->getParamType(i)); + to = getWidthForLLVMType(fType->getParamType(i)); if (from != to) { // XXX need to check other param attrs ? @@ -1894,35 +1894,35 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { CastInst *ci = cast<CastInst>(i); ref<Expr> result = ExtractExpr::create(eval(ki, 0, state).value, 0, - Expr::getWidthForLLVMType(ci->getType())); + getWidthForLLVMType(ci->getType())); bindLocal(ki, state, result); break; } case Instruction::ZExt: { CastInst *ci = cast<CastInst>(i); ref<Expr> result = ZExtExpr::create(eval(ki, 0, state).value, - Expr::getWidthForLLVMType(ci->getType())); + getWidthForLLVMType(ci->getType())); bindLocal(ki, state, result); break; } case Instruction::SExt: { CastInst *ci = cast<CastInst>(i); ref<Expr> result = SExtExpr::create(eval(ki, 0, state).value, - Expr::getWidthForLLVMType(ci->getType())); + getWidthForLLVMType(ci->getType())); bindLocal(ki, state, result); break; } case Instruction::IntToPtr: { CastInst *ci = cast<CastInst>(i); - Expr::Width pType = Expr::getWidthForLLVMType(ci->getType()); + Expr::Width pType = getWidthForLLVMType(ci->getType()); ref<Expr> arg = eval(ki, 0, state).value; bindLocal(ki, state, ZExtExpr::create(arg, pType)); break; } case Instruction::PtrToInt: { CastInst *ci = cast<CastInst>(i); - Expr::Width iType = Expr::getWidthForLLVMType(ci->getType()); + Expr::Width iType = getWidthForLLVMType(ci->getType()); ref<Expr> arg = eval(ki, 0, state).value; bindLocal(ki, state, ZExtExpr::create(arg, iType)); break; @@ -2013,7 +2013,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::FPTrunc: { FPTruncInst *fi = cast<FPTruncInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); if (!fpWidthToSemantics(arg->getWidth()) || resultType > arg->getWidth()) @@ -2030,7 +2030,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::FPExt: { FPExtInst *fi = cast<FPExtInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); if (!fpWidthToSemantics(arg->getWidth()) || arg->getWidth() > resultType) @@ -2047,7 +2047,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::FPToUI: { FPToUIInst *fi = cast<FPToUIInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); if (!fpWidthToSemantics(arg->getWidth()) || resultType > 64) @@ -2064,7 +2064,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::FPToSI: { FPToSIInst *fi = cast<FPToSIInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); if (!fpWidthToSemantics(arg->getWidth()) || resultType > 64) @@ -2081,7 +2081,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::UIToFP: { UIToFPInst *fi = cast<UIToFPInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); const llvm::fltSemantics *semantics = fpWidthToSemantics(resultType); @@ -2097,7 +2097,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::SIToFP: { SIToFPInst *fi = cast<SIToFPInst>(i); - Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType()); + Expr::Width resultType = getWidthForLLVMType(fi->getType()); ref<ConstantExpr> arg = toConstant(state, eval(ki, 0, state).value, "floating point"); const llvm::fltSemantics *semantics = fpWidthToSemantics(resultType); @@ -2654,7 +2654,7 @@ void Executor::callExternalFunction(ExecutionState &state, const Type *resultType = target->inst->getType(); if (resultType != Type::getVoidTy(getGlobalContext())) { ref<Expr> e = ConstantExpr::fromMemory((void*) args, - Expr::getWidthForLLVMType(resultType)); + getWidthForLLVMType(resultType)); bindLocal(target, state, e); } } @@ -2883,7 +2883,7 @@ void Executor::executeMemoryOperation(ExecutionState &state, ref<Expr> value /* undef if read */, KInstruction *target /* undef if write */) { Expr::Width type = (isWrite ? value->getWidth() : - Expr::getWidthForLLVMType(target->inst->getType())); + getWidthForLLVMType(target->inst->getType())); unsigned bytes = Expr::getMinBytesForWidth(type); if (SimplifySymIndices) { @@ -3292,6 +3292,10 @@ void Executor::doImpliedValueConcretization(ExecutionState &state, } } +Expr::Width Executor::getWidthForLLVMType(const llvm::Type *type) const { + return kmodule->targetData->getTypeSizeInBits(type); +} + /// Interpreter *Interpreter::create(const InterpreterOptions &opts, |