diff options
Diffstat (limited to 'lib/Core')
-rw-r--r-- | lib/Core/Executor.cpp | 30 | ||||
-rw-r--r-- | lib/Core/Executor.h | 8 | ||||
-rw-r--r-- | lib/Core/ExecutorUtil.cpp | 6 | ||||
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 14 |
4 files changed, 34 insertions, 24 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index e46ff9b0..48a8b57a 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -376,10 +376,10 @@ Executor::~Executor() { /***/ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os, - Constant *c, + const Constant *c, unsigned offset) { TargetData *targetData = kmodule->targetData; - if (ConstantVector *cp = dyn_cast<ConstantVector>(c)) { + if (const ConstantVector *cp = dyn_cast<ConstantVector>(c)) { unsigned elementSize = targetData->getTypeStoreSize(cp->getType()->getElementType()); for (unsigned i=0, e=cp->getNumOperands(); i != e; ++i) @@ -389,13 +389,13 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os, unsigned i, size = targetData->getTypeStoreSize(c->getType()); for (i=0; i<size; i++) os->write8(offset+i, (uint8_t) 0); - } else if (ConstantArray *ca = dyn_cast<ConstantArray>(c)) { + } else if (const ConstantArray *ca = dyn_cast<ConstantArray>(c)) { unsigned elementSize = targetData->getTypeStoreSize(ca->getType()->getElementType()); for (unsigned i=0, e=ca->getNumOperands(); i != e; ++i) initializeGlobalObject(state, os, ca->getOperand(i), offset + i*elementSize); - } else if (ConstantStruct *cs = dyn_cast<ConstantStruct>(c)) { + } else if (const ConstantStruct *cs = dyn_cast<ConstantStruct>(c)) { const StructLayout *sl = targetData->getStructLayout(cast<StructType>(cs->getType())); for (unsigned i=0, e=cs->getNumOperands(); i != e; ++i) @@ -501,7 +501,7 @@ void Executor::initializeGlobals(ExecutionState &state) { // better we could support user definition, or use the EXE style // hack where we check the object file information. - const Type *ty = i->getType()->getElementType(); + LLVM_TYPE_Q Type *ty = i->getType()->getElementType(); uint64_t size = kmodule->targetData->getTypeStoreSize(ty); // XXX - DWD - hardcode some things until we decide how to fix. @@ -544,7 +544,7 @@ void Executor::initializeGlobals(ExecutionState &state) { os->write8(offset, ((unsigned char*)addr)[offset]); } } else { - const Type *ty = i->getType()->getElementType(); + LLVM_TYPE_Q Type *ty = i->getType()->getElementType(); uint64_t size = kmodule->targetData->getTypeStoreSize(ty); MemoryObject *mo = 0; @@ -931,8 +931,8 @@ void Executor::addConstraint(ExecutionState &state, ref<Expr> condition) { ConstantExpr::alloc(1, Expr::Bool)); } -ref<klee::ConstantExpr> Executor::evalConstant(Constant *c) { - if (llvm::ConstantExpr *ce = dyn_cast<llvm::ConstantExpr>(c)) { +ref<klee::ConstantExpr> Executor::evalConstant(const Constant *c) { + if (const llvm::ConstantExpr *ce = dyn_cast<llvm::ConstantExpr>(c)) { return evalConstantExpr(ce); } else { if (const ConstantInt *ci = dyn_cast<ConstantInt>(c)) { @@ -1375,7 +1375,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { } if (!isVoidReturn) { - const Type *t = caller->getType(); + LLVM_TYPE_Q Type *t = caller->getType(); if (t != Type::getVoidTy(getGlobalContext())) { // may need to do coercion due to bitcasts Expr::Width from = result->getWidth(); @@ -1462,7 +1462,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { if (ConstantExpr *CE = dyn_cast<ConstantExpr>(cond)) { // Somewhat gross to create these all the time, but fine till we // switch to an internal rep. - const llvm::IntegerType *Ty = + LLVM_TYPE_Q llvm::IntegerType *Ty = cast<IntegerType>(si->getCondition()->getType()); ConstantInt *ci = ConstantInt::get(Ty, CE->getZExtValue()); unsigned index = si->findCaseValue(ci); @@ -1627,7 +1627,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { break; } case Instruction::PHI: { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + ref<Expr> result = eval(ki, state.incomingBBIndex, state).value; +#else ref<Expr> result = eval(ki, state.incomingBBIndex * 2, state).value; +#endif bindLocal(ki, state, result); break; } @@ -2303,7 +2307,7 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) { ConstantExpr::alloc(0, Context::get().getPointerWidth()); uint64_t index = 1; for (TypeIt ii = ib; ii != ie; ++ii) { - if (const StructType *st = dyn_cast<StructType>(*ii)) { + if (LLVM_TYPE_Q StructType *st = dyn_cast<StructType>(*ii)) { const StructLayout *sl = kmodule->targetData->getStructLayout(st); const ConstantInt *ci = cast<ConstantInt>(ii.getOperand()); uint64_t addend = sl->getElementOffset((unsigned) ci->getZExtValue()); @@ -2713,7 +2717,7 @@ void Executor::callExternalFunction(ExecutionState &state, return; } - const Type *resultType = target->inst->getType(); + LLVM_TYPE_Q Type *resultType = target->inst->getType(); if (resultType != Type::getVoidTy(getGlobalContext())) { ref<Expr> e = ConstantExpr::fromMemory((void*) args, getWidthForLLVMType(resultType)); @@ -3360,7 +3364,7 @@ void Executor::doImpliedValueConcretization(ExecutionState &state, } } -Expr::Width Executor::getWidthForLLVMType(const llvm::Type *type) const { +Expr::Width Executor::getWidthForLLVMType(LLVM_TYPE_Q llvm::Type *type) const { return kmodule->targetData->getTypeSizeInBits(type); } diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h index 3a0fa139..3df4cc88 100644 --- a/lib/Core/Executor.h +++ b/lib/Core/Executor.h @@ -184,7 +184,7 @@ private: unsigned size, bool isReadOnly); void initializeGlobalObject(ExecutionState &state, ObjectState *os, - llvm::Constant *c, + const llvm::Constant *c, unsigned offset); void initializeGlobals(ExecutionState &state); @@ -309,7 +309,7 @@ private: ExecutionState &state, ref<Expr> value); - ref<klee::ConstantExpr> evalConstantExpr(llvm::ConstantExpr *ce); + ref<klee::ConstantExpr> evalConstantExpr(const llvm::ConstantExpr *ce); /// Return a unique constant value for the given expression in the /// given state, if it has one (i.e. it provably only has a single @@ -390,7 +390,7 @@ public: } // XXX should just be moved out to utility module - ref<klee::ConstantExpr> evalConstant(llvm::Constant *c); + ref<klee::ConstantExpr> evalConstant(const llvm::Constant *c); virtual void setPathWriter(TreeStreamWriter *tsw) { pathWriter = tsw; @@ -452,7 +452,7 @@ public: virtual void getCoveredLines(const ExecutionState &state, std::map<const std::string*, std::set<unsigned> > &res); - Expr::Width getWidthForLLVMType(const llvm::Type *type) const; + Expr::Width getWidthForLLVMType(LLVM_TYPE_Q llvm::Type *type) const; }; } // End klee namespace diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index 02f18bb4..6ab021c1 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -37,8 +37,8 @@ using namespace llvm; namespace klee { - ref<ConstantExpr> Executor::evalConstantExpr(llvm::ConstantExpr *ce) { - const llvm::Type *type = ce->getType(); + ref<ConstantExpr> Executor::evalConstantExpr(const llvm::ConstantExpr *ce) { + LLVM_TYPE_Q llvm::Type *type = ce->getType(); ref<ConstantExpr> op1(0), op2(0), op3(0); int numOperands = ce->getNumOperands(); @@ -87,7 +87,7 @@ namespace klee { ref<ConstantExpr> addend = ConstantExpr::alloc(0, Context::get().getPointerWidth()); - if (const StructType *st = dyn_cast<StructType>(*ii)) { + if (LLVM_TYPE_Q StructType *st = dyn_cast<StructType>(*ii)) { const StructLayout *sl = kmodule->targetData->getStructLayout(st); const ConstantInt *ci = cast<ConstantInt>(ii.getOperand()); diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 5c03e42d..c876685e 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -209,7 +209,7 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in Value **args = new Value*[cs.arg_size()]; - std::vector<const Type*> nullary; + std::vector<LLVM_TYPE_Q Type*> nullary; Function *dispatcher = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), nullary, false), @@ -229,7 +229,7 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in Instruction *argI64s = new LoadInst(argI64sp, "args", dBB); // Get the target function type. - const FunctionType *FTy = + LLVM_TYPE_Q FunctionType *FTy = cast<FunctionType>(cast<PointerType>(target->getType())->getElementType()); // Each argument will be passed by writing it into gTheArgsP[i]. @@ -239,8 +239,8 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in // Determine the type the argument will be passed as. This accomodates for // the corresponding code in Executor.cpp for handling calls to bitcasted // functions. - const Type *argTy = (i < FTy->getNumParams() ? FTy->getParamType(i) : - (*ai)->getType()); + LLVM_TYPE_Q Type *argTy = (i < FTy->getNumParams() ? FTy->getParamType(i) : + (*ai)->getType()); Instruction *argI64p = GetElementPtrInst::Create(argI64s, ConstantInt::get(Type::getInt32Ty(getGlobalContext()), @@ -258,7 +258,13 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in Constant *dispatchTarget = dispatchModule->getOrInsertFunction(target->getName(), FTy, target->getAttributes()); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + Instruction *result = CallInst::Create(dispatchTarget, + llvm::ArrayRef<Value *>(args, args+i), + "", dBB); +#else Instruction *result = CallInst::Create(dispatchTarget, args, args+i, "", dBB); +#endif if (result->getType() != Type::getVoidTy(getGlobalContext())) { Instruction *resp = new BitCastInst(argI64s, PointerType::getUnqual(result->getType()), |