diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-17 00:54:57 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-17 00:54:57 +0000 |
commit | 36c9fe87bb38d20850ca50d60facd019af54aa30 (patch) | |
tree | 6c26f044da7a248b497fd9e362f1344b87189844 | |
parent | 1d539296be5701036e8c48dac75add46eaf03a3f (diff) | |
download | klee-36c9fe87bb38d20850ca50d60facd019af54aa30.tar.gz |
Update for LLVM API change.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@79217 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Core/Executor.cpp | 4 | ||||
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 16 | ||||
-rw-r--r-- | lib/Module/Checks.cpp | 7 | ||||
-rw-r--r-- | lib/Module/IntrinsicCleaner.cpp | 6 | ||||
-rw-r--r-- | lib/Module/KModule.cpp | 40 | ||||
-rw-r--r-- | lib/Module/LowerSwitch.cpp | 4 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 4 | ||||
-rw-r--r-- | test/Makefile | 4 | ||||
-rw-r--r-- | tools/klee/main.cpp | 33 |
9 files changed, 62 insertions, 56 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index c69570ae..35238793 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -1337,7 +1337,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { if (!isVoidReturn) { const Type *t = caller->getType(); - if (t != Type::VoidTy) { + if (t != Type::getVoidTy(getGlobalContext())) { // may need to do coercion due to bitcasts Expr::Width from = result->getWidth(); Expr::Width to = Expr::getWidthForLLVMType(t); @@ -2623,7 +2623,7 @@ void Executor::callExternalFunction(ExecutionState &state, } const Type *resultType = target->inst->getType(); - if (resultType != Type::VoidTy) { + if (resultType != Type::getVoidTy(getGlobalContext())) { ref<Expr> e = ConstantExpr::fromMemory((void*) args, Expr::getWidthForLLVMType(resultType)); bindLocal(target, state, e); diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 767fafda..e5b00b7f 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -188,20 +188,20 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in std::vector<const Type*> nullary; - Function *dispatcher = Function::Create(FunctionType::get(Type::VoidTy, + Function *dispatcher = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), nullary, false), GlobalVariable::ExternalLinkage, "", dispatchModule); - BasicBlock *dBB = BasicBlock::Create("entry", dispatcher); + BasicBlock *dBB = BasicBlock::Create(getGlobalContext(), "entry", dispatcher); // Get a Value* for &gTheArgsP, as an i64**. Instruction *argI64sp = - new IntToPtrInst(ConstantInt::get(Type::Int64Ty, + new IntToPtrInst(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (uintptr_t) (void*) &gTheArgsP), - PointerType::getUnqual(PointerType::getUnqual(Type::Int64Ty)), + PointerType::getUnqual(PointerType::getUnqual(Type::getInt64Ty(getGlobalContext()))), "argsp", dBB); Instruction *argI64s = new LoadInst(argI64sp, "args", dBB); @@ -219,7 +219,9 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in const Type *argTy = (i < FTy->getNumParams() ? FTy->getParamType(i) : (*ai)->getType()); Instruction *argI64p = - GetElementPtrInst::Create(argI64s, ConstantInt::get(Type::Int32Ty, i+1), + GetElementPtrInst::Create(argI64s, + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + i+1), "", dBB); Instruction *argp = new BitCastInst(argI64p, PointerType::getUnqual(argTy), @@ -228,14 +230,14 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in } Instruction *result = CallInst::Create(target, args, args+i, "", dBB); - if (result->getType() != Type::VoidTy) { + if (result->getType() != Type::getVoidTy(getGlobalContext())) { Instruction *resp = new BitCastInst(argI64s, PointerType::getUnqual(result->getType()), "", dBB); new StoreInst(result, resp, dBB); } - ReturnInst::Create(dBB); + ReturnInst::Create(getGlobalContext(), dBB); delete[] args; diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index ca4eeb44..ee7029c7 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -44,7 +44,7 @@ bool DivCheckPass::runOnModule(Module &M) { CastInst *denominator = CastInst::CreateIntegerCast(i->getOperand(1), - (Type*)Type::Int64Ty, + Type::getInt64Ty(getGlobalContext()), false, /* sign doesn't matter */ "int_cast_to_i64", i); @@ -52,8 +52,9 @@ bool DivCheckPass::runOnModule(Module &M) { // Lazily bind the function to avoid always importing it. if (!divZeroCheckFunction) { Constant *fc = M.getOrInsertFunction("klee_div_zero_check", - Type::VoidTy, - Type::Int64Ty, NULL); + Type::getVoidTy(getGlobalContext()), + Type::getInt64Ty(getGlobalContext()), + NULL); divZeroCheckFunction = cast<Function>(fc); } diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 4f490e8e..a73d8ca6 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -61,18 +61,18 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) { Value *src = ii->getOperand(2); if (WordSize == 4) { - Type *i8pp = PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)); + Type *i8pp = PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))); Value *castedDst = CastInst::CreatePointerCast(dst, i8pp, "vacopy.cast.dst", ii); Value *castedSrc = CastInst::CreatePointerCast(src, i8pp, "vacopy.cast.src", ii); Value *load = new LoadInst(castedSrc, "vacopy.read", ii); new StoreInst(load, castedDst, false, ii); } else { assert(WordSize == 8 && "Invalid word size!"); - Type *i64p = PointerType::getUnqual(Type::Int64Ty); + Type *i64p = PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())); Value *pDst = CastInst::CreatePointerCast(dst, i64p, "vacopy.cast.dst", ii); Value *pSrc = CastInst::CreatePointerCast(src, i64p, "vacopy.cast.src", ii); Value *val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii); - Value *off = ConstantInt::get(Type::Int64Ty, 1); + Value *off = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 1); pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii); pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii); val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii); diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 78ecf4d1..37e869c8 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -112,12 +112,12 @@ static Function *getStubFunctionForCtorList(Module *m, std::vector<const Type*> nullary; - Function *fn = Function::Create(FunctionType::get(Type::VoidTy, + Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), nullary, false), GlobalVariable::InternalLinkage, name, m); - BasicBlock *bb = BasicBlock::Create("entry", fn); + BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", fn); // From lli: // Should be an array of '{ int, void ()* }' structs. The first value is @@ -142,7 +142,7 @@ static Function *getStubFunctionForCtorList(Module *m, } } - ReturnInst::Create(bb); + ReturnInst::Create(getGlobalContext(), bb); return fn; } @@ -197,7 +197,8 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, Function *mergeFn = module->getFunction("klee_merge"); if (!mergeFn) { const llvm::FunctionType *Ty = - FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false); + FunctionType::get(Type::getVoidTy(getGlobalContext()), + std::vector<const Type*>(), false); mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage, "klee_merge", module); @@ -215,12 +216,12 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, name.c_str()); } - BasicBlock *exit = BasicBlock::Create("exit", f); + BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f); PHINode *result = 0; - if (f->getReturnType() != Type::VoidTy) + if (f->getReturnType() != Type::getVoidTy(getGlobalContext())) result = PHINode::Create(f->getReturnType(), "retval", exit); CallInst::Create(mergeFn, "", exit); - ReturnInst::Create(result, exit); + ReturnInst::Create(getGlobalContext(), result, exit); llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n"; for (llvm::Function::iterator bbit = f->begin(), bbie = f->end(); @@ -263,18 +264,19 @@ 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. - forceImport(module, "memcpy", PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - targetData->getIntPtrType(), (Type*) 0); - forceImport(module, "memmove", PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - targetData->getIntPtrType(), (Type*) 0); - forceImport(module, "memset", PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - Type::Int32Ty, - targetData->getIntPtrType(), (Type*) 0); + const llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); + forceImport(module, "memcpy", PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + targetData->getIntPtrType(getGlobalContext()), (Type*) 0); + forceImport(module, "memmove", PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + targetData->getIntPtrType(getGlobalContext()), (Type*) 0); + forceImport(module, "memset", PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + Type::getInt32Ty(getGlobalContext()), + targetData->getIntPtrType(getGlobalContext()), (Type*) 0); // FIXME: Missing force import for various math functions. diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp index a2033eae..381ebd29 100644 --- a/lib/Module/LowerSwitch.cpp +++ b/lib/Module/LowerSwitch.cpp @@ -60,7 +60,7 @@ void LowerSwitchPass::switchConvert(CaseItr begin, CaseItr end, // iterate through all the cases, creating a new BasicBlock for each for (CaseItr it = begin; it < end; ++it) { - BasicBlock *newBlock = BasicBlock::Create("NodeBlock"); + BasicBlock *newBlock = BasicBlock::Create(getGlobalContext(), "NodeBlock"); Function::iterator FI = origBlock; F->getBasicBlockList().insert(++FI, newBlock); @@ -96,7 +96,7 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) { // Create a new, empty default block so that the new hierarchy of // if-then statements go to this and the PHI nodes are happy. - BasicBlock* newDefault = BasicBlock::Create("newDefault"); + BasicBlock* newDefault = BasicBlock::Create(getGlobalContext(), "newDefault"); F->getBasicBlockList().insert(defaultBlock, newDefault); BranchInst::Create(defaultBlock, newDefault); diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 67fbf8ae..b62338a6 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -35,10 +35,10 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { // bswaps if (ci->getNumOperands() == 2 && T == ci->getOperand(1)->getType() && - ((T == llvm::Type::Int16Ty && + ((T == llvm::Type::getInt16Ty(getGlobalContext()) && as == "rorw $$8, ${0:w}" && cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}") || - (T == llvm::Type::Int32Ty && + (T == llvm::Type::getInt32Ty(getGlobalContext()) && as == "rorw $$8, ${0:w};rorl $$16, $0;rorw $$8, ${0:w}" && cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}"))) { llvm::Value *Arg0 = ci->getOperand(1); diff --git a/test/Makefile b/test/Makefile index 0c42a6f6..8cd8688a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -89,8 +89,8 @@ site.exp: Makefile $(LEVEL)/Makefile.config @echo 'set compile_c "$(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c "' >>site.tmp @echo 'set compile_cxx "$(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) - c"' >> site.tmp @echo 'set link "$(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags)"' >>site.tmp - @echo 'set llvmgcc "$(LLVMGCC)"' >> site.tmp - @echo 'set llvmgxx "$(LLVMGCC)"' >> site.tmp + @echo 'set llvmgcc "$(LLVMGCC) -m32"' >> site.tmp + @echo 'set llvmgxx "$(LLVMGCC) -m32"' >> site.tmp @echo 'set llvmgccmajvers "$(LLVMGCC_MAJVERS)"' >> site.tmp @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index f3222336..f7a8f0bf 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -618,11 +618,11 @@ static int initEnv(Module *mainModule) { /* Insert void klee_init_env(int* argc, char*** argv) */ std::vector<const Type*> params; - params.push_back(Type::Int32Ty); - params.push_back(Type::Int32Ty); + params.push_back(Type::getInt32Ty(getGlobalContext())); + params.push_back(Type::getInt32Ty(getGlobalContext())); Function* initEnvFn = cast<Function>(mainModule->getOrInsertFunction("klee_init_env", - Type::VoidTy, + Type::getVoidTy(getGlobalContext()), argcPtr->getType(), argvPtr->getType(), NULL)); @@ -928,28 +928,29 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { Function *f; // force import of __uClibc_main mainModule->getOrInsertFunction("__uClibc_main", - FunctionType::get(Type::VoidTy, + FunctionType::get(Type::getVoidTy(getGlobalContext()), std::vector<const Type*>(), true)); // force various imports if (WithPOSIXRuntime) { + const llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); mainModule->getOrInsertFunction("realpath", - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), + PointerType::getUnqual(i8Ty), NULL); mainModule->getOrInsertFunction("getutent", - PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(i8Ty), NULL); mainModule->getOrInsertFunction("__fgetc_unlocked", - Type::Int32Ty, - PointerType::getUnqual(Type::Int8Ty), + Type::getInt32Ty(getGlobalContext()), + PointerType::getUnqual(i8Ty), NULL); mainModule->getOrInsertFunction("__fputc_unlocked", - Type::Int32Ty, - Type::Int32Ty, - PointerType::getUnqual(Type::Int8Ty), + Type::getInt32Ty(getGlobalContext()), + Type::getInt32Ty(getGlobalContext()), + PointerType::getUnqual(i8Ty), NULL); } @@ -1039,11 +1040,11 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { std::vector<const Type*> fArgs; fArgs.push_back(ft->getParamType(1)); // argc fArgs.push_back(ft->getParamType(2)); // argv - Function *stub = Function::Create(FunctionType::get(Type::Int32Ty, fArgs, false), + Function *stub = Function::Create(FunctionType::get(Type::getInt32Ty(getGlobalContext()), fArgs, false), GlobalVariable::ExternalLinkage, "main", mainModule); - BasicBlock *bb = BasicBlock::Create("entry", stub); + BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", stub); std::vector<llvm::Value*> args; args.push_back(llvm::ConstantExpr::getBitCast(userMainFn, @@ -1056,7 +1057,7 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { args.push_back(Constant::getNullValue(ft->getParamType(6))); // stack_end CallInst::Create(uclibcMainFn, args.begin(), args.end(), "", bb); - new UnreachableInst(bb); + new UnreachableInst(getGlobalContext(), bb); return mainModule; } |