diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-07-20 18:36:48 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-07-20 18:36:48 +0000 |
commit | b640fcf217c848ad051977018c6dc8f3a5a37e1f (patch) | |
tree | 70c49e15714efdd13bfa096352701638c3b23db1 | |
parent | ed9ea0cf9dc856920afc6813fa1bea0ec7660ba1 (diff) | |
download | klee-b640fcf217c848ad051977018c6dc8f3a5a37e1f.tar.gz |
Updates for LLVM 3.0. Based on changes by arrowdodger, thanks!
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@135598 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/klee/Config/Version.h | 6 | ||||
-rw-r--r-- | include/klee/util/GetElementPtrTypeIterator.h | 27 | ||||
-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 | ||||
-rw-r--r-- | lib/Module/KModule.cpp | 15 | ||||
-rw-r--r-- | lib/Module/Optimize.cpp | 2 | ||||
-rw-r--r-- | lib/Module/Passes.h | 4 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 11 | ||||
-rw-r--r-- | test/regression/2007-08-01-bool-zext-in-call.ll | 2 | ||||
-rw-r--r-- | tools/klee/main.cpp | 15 |
12 files changed, 91 insertions, 49 deletions
diff --git a/include/klee/Config/Version.h b/include/klee/Config/Version.h index f5adaa66..ea2af961 100644 --- a/include/klee/Config/Version.h +++ b/include/klee/Config/Version.h @@ -15,4 +15,10 @@ #define LLVM_VERSION(major, minor) (((major) << 8) | (minor)) #define LLVM_VERSION_CODE LLVM_VERSION(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) +# define LLVM_TYPE_Q +#else +# define LLVM_TYPE_Q const +#endif + #endif diff --git a/include/klee/util/GetElementPtrTypeIterator.h b/include/klee/util/GetElementPtrTypeIterator.h index 302c19ef..4446914d 100644 --- a/include/klee/util/GetElementPtrTypeIterator.h +++ b/include/klee/util/GetElementPtrTypeIterator.h @@ -18,6 +18,8 @@ #ifndef KLEE_UTIL_GETELEMENTPTRTYPE_H #define KLEE_UTIL_GETELEMENTPTRTYPE_H +#include "klee/Config/Version.h" + #include "llvm/User.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -29,12 +31,13 @@ namespace klee { template<typename ItTy = llvm::User::const_op_iterator> class generic_gep_type_iterator - : public std::iterator<std::forward_iterator_tag, const llvm::Type *, ptrdiff_t> { + : public std::iterator<std::forward_iterator_tag, + LLVM_TYPE_Q llvm::Type *, ptrdiff_t> { typedef std::iterator<std::forward_iterator_tag, - const llvm::Type *, ptrdiff_t> super; + LLVM_TYPE_Q llvm::Type *, ptrdiff_t> super; ItTy OpIt; - const llvm::Type *CurTy; + LLVM_TYPE_Q llvm::Type *CurTy; generic_gep_type_iterator() {} llvm::Value *asValue(llvm::Value *V) const { return V; } @@ -44,7 +47,8 @@ namespace klee { public: - static generic_gep_type_iterator begin(const llvm::Type *Ty, ItTy It) { + static generic_gep_type_iterator begin(LLVM_TYPE_Q llvm::Type *Ty, + ItTy It) { generic_gep_type_iterator I; I.CurTy = Ty; I.OpIt = It; @@ -64,23 +68,24 @@ namespace klee { return !operator==(x); } - const llvm::Type *operator*() const { + LLVM_TYPE_Q llvm::Type *operator*() const { return CurTy; } - const llvm::Type *getIndexedType() const { - const llvm::CompositeType *CT = cast<llvm::CompositeType>(CurTy); + LLVM_TYPE_Q llvm::Type *getIndexedType() const { + LLVM_TYPE_Q llvm::CompositeType *CT = cast<llvm::CompositeType>(CurTy); return CT->getTypeAtIndex(getOperand()); } // This is a non-standard operator->. It allows you to call methods on the // current type directly. - const llvm::Type *operator->() const { return operator*(); } + LLVM_TYPE_Q llvm::Type *operator->() const { return operator*(); } llvm::Value *getOperand() const { return asValue(*OpIt); } generic_gep_type_iterator& operator++() { // Preincrement - if (const llvm::CompositeType *CT = dyn_cast<llvm::CompositeType>(CurTy)) { + if (LLVM_TYPE_Q llvm::CompositeType *CT = + dyn_cast<llvm::CompositeType>(CurTy)) { CurTy = CT->getTypeAtIndex(getOperand()); } else { CurTy = 0; @@ -140,13 +145,13 @@ namespace klee { template<typename ItTy> inline generic_gep_type_iterator<ItTy> - gep_type_begin(const llvm::Type *Op0, ItTy I, ItTy E) { + gep_type_begin(LLVM_TYPE_Q llvm::Type *Op0, ItTy I, ItTy E) { return generic_gep_type_iterator<ItTy>::begin(Op0, I); } template<typename ItTy> inline generic_gep_type_iterator<ItTy> - gep_type_end(const llvm::Type *Op0, ItTy I, ItTy E) { + gep_type_end(LLVM_TYPE_Q llvm::Type *Op0, ItTy I, ItTy E) { return generic_gep_type_iterator<ItTy>::end(E); } } // end namespace klee 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()), diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 94c3d05b..a569242e 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -122,7 +122,7 @@ static Function *getStubFunctionForCtorList(Module *m, assert(!gv->isDeclaration() && !gv->hasInternalLinkage() && "do not support old LLVM style constructor/destructor lists"); - std::vector<const Type*> nullary; + std::vector<LLVM_TYPE_Q Type*> nullary; Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), nullary, false), @@ -181,7 +181,8 @@ static void injectStaticConstructorsAndDestructors(Module *m) { } } -static void forceImport(Module *m, const char *name, const Type *retType, ...) { +static void forceImport(Module *m, const char *name, LLVM_TYPE_Q Type *retType, + ...) { // If module lacks an externally visible symbol for the name then we // need to create one. We have to look in the symbol table because // we want to check everything (global variables, functions, and @@ -194,8 +195,8 @@ static void forceImport(Module *m, const char *name, const Type *retType, ...) { va_list ap; va_start(ap, retType); - std::vector<const Type *> argTypes; - while (const Type *t = va_arg(ap, const Type*)) + std::vector<LLVM_TYPE_Q Type *> argTypes; + while (LLVM_TYPE_Q Type *t = va_arg(ap, LLVM_TYPE_Q Type*)) argTypes.push_back(t); va_end(ap); @@ -208,9 +209,9 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, if (!MergeAtExit.empty()) { Function *mergeFn = module->getFunction("klee_merge"); if (!mergeFn) { - const llvm::FunctionType *Ty = + LLVM_TYPE_Q llvm::FunctionType *Ty = FunctionType::get(Type::getVoidTy(getGlobalContext()), - std::vector<const Type*>(), false); + std::vector<LLVM_TYPE_Q Type*>(), false); mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage, "klee_merge", module); @@ -280,7 +281,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, // by name. We only add them if such a function doesn't exist to // avoid creating stale uses. - const llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); + LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); forceImport(module, "memcpy", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index e0ae4d99..524f80e2 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -158,7 +158,9 @@ static void AddStandardCompilePasses(PassManager &PM) { addPass(PM, createAggressiveDCEPass()); // Delete dead instructions addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createStripDeadPrototypesPass()); // Get rid of dead prototypes +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) addPass(PM, createDeadTypeEliminationPass()); // Eliminate dead types +#endif addPass(PM, createConstantMergePass()); // Merge dup global constants } diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h index 480fbde6..6257da8f 100644 --- a/lib/Module/Passes.h +++ b/lib/Module/Passes.h @@ -40,11 +40,11 @@ class RaiseAsmPass : public llvm::ModulePass { llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, - const llvm::Type **Tys, + LLVM_TYPE_Q llvm::Type **Tys, unsigned NumTys); llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, - const llvm::Type *Ty0) { + LLVM_TYPE_Q llvm::Type *Ty0) { return getIntrinsic(M, IID, &Ty0, 1); } diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 8f862ffa..6f6a5c90 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -28,9 +28,14 @@ char RaiseAsmPass::ID = 0; Function *RaiseAsmPass::getIntrinsic(llvm::Module &M, unsigned IID, - const Type **Tys, + LLVM_TYPE_Q Type **Tys, unsigned NumTys) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + return Intrinsic::getDeclaration(&M, (llvm::Intrinsic::ID) IID, + llvm::ArrayRef<llvm::Type*>(Tys, NumTys)); +#else return Intrinsic::getDeclaration(&M, (llvm::Intrinsic::ID) IID, Tys, NumTys); +#endif } // FIXME: This should just be implemented as a patch to @@ -87,7 +92,11 @@ bool RaiseAsmPass::runOnModule(Module &M) { llvm::errs() << "Warning: unable to select native target: " << Err << "\n"; TLI = 0; } else { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + TargetMachine *TM = NativeTarget->createTargetMachine(HostTriple, "", ""); +#else TargetMachine *TM = NativeTarget->createTargetMachine(HostTriple, ""); +#endif TLI = TM->getTargetLowering(); } #endif diff --git a/test/regression/2007-08-01-bool-zext-in-call.ll b/test/regression/2007-08-01-bool-zext-in-call.ll index 3f3e26ab..d10a41ef 100644 --- a/test/regression/2007-08-01-bool-zext-in-call.ll +++ b/test/regression/2007-08-01-bool-zext-in-call.ll @@ -9,7 +9,7 @@ define i32 @foo(i8 signext %val) { } define i32 @main() { - %res = call i32 bitcast (i32 (i8 signext)* @foo to i32 (i1)*)( i1 1 ) + %res = call i32 bitcast (i32 (i8)* @foo to i32 (i1)*)( i1 1 ) %check = icmp ne i32 %res, 255 br i1 %check, label %error, label %exit diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 12f90f2a..16cc6283 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -637,8 +637,13 @@ static int initEnv(Module *mainModule) { std::vector<Value*> args; args.push_back(argcPtr); args.push_back(argvPtr); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + Instruction* initEnvCall = CallInst::Create(initEnvFn, args, + "", firstInst); +#else Instruction* initEnvCall = CallInst::Create(initEnvFn, args.begin(), args.end(), "", firstInst); +#endif Value *argc = new LoadInst(argcPtr, "newArgc", firstInst); Value *argv = new LoadInst(argvPtr, "newArgv", firstInst); @@ -937,12 +942,12 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { // force import of __uClibc_main mainModule->getOrInsertFunction("__uClibc_main", FunctionType::get(Type::getVoidTy(getGlobalContext()), - std::vector<const Type*>(), + std::vector<LLVM_TYPE_Q Type*>(), true)); // force various imports if (WithPOSIXRuntime) { - const llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); + LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); mainModule->getOrInsertFunction("realpath", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), @@ -1045,7 +1050,7 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { const FunctionType *ft = uclibcMainFn->getFunctionType(); assert(ft->getNumParams() == 7); - std::vector<const Type*> fArgs; + std::vector<LLVM_TYPE_Q Type*> fArgs; fArgs.push_back(ft->getParamType(1)); // argc fArgs.push_back(ft->getParamType(2)); // argv Function *stub = Function::Create(FunctionType::get(Type::getInt32Ty(getGlobalContext()), fArgs, false), @@ -1063,7 +1068,11 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { args.push_back(Constant::getNullValue(ft->getParamType(4))); // app_fini args.push_back(Constant::getNullValue(ft->getParamType(5))); // rtld_fini args.push_back(Constant::getNullValue(ft->getParamType(6))); // stack_end +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) + CallInst::Create(uclibcMainFn, args, "", bb); +#else CallInst::Create(uclibcMainFn, args.begin(), args.end(), "", bb); +#endif new UnreachableInst(getGlobalContext(), bb); |