diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2017-02-22 16:10:21 +0100 |
---|---|---|
committer | Jiri Slaby <jirislaby@gmail.com> | 2017-02-25 11:11:04 +0100 |
commit | 4c8fabc7de30e17ef116b8f413f3a973c29cb56c (patch) | |
tree | 29e23676c07a95e83c58b5bcb5f8fd4189efaf45 /lib/Module/KModule.cpp | |
parent | 1b67624c3a2fc1ca6f60d0a2b0f675d046dbba76 (diff) | |
download | klee-4c8fabc7de30e17ef116b8f413f3a973c29cb56c.tar.gz |
llvm: stop using global context
It was marked as deprecated long time ago and finally removed in LLVM 3.9. Remove all uses of getGlobalContext and create our own context. Propagate it all over the code then. [v2] use ctx, not C as name Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'lib/Module/KModule.cpp')
-rw-r--r-- | lib/Module/KModule.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 57346a31..3259873e 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -144,12 +144,12 @@ static Function *getStubFunctionForCtorList(Module *m, std::vector<LLVM_TYPE_Q Type*> nullary; - Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), + Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(m->getContext()), nullary, false), GlobalVariable::InternalLinkage, name, m); - BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", fn); + BasicBlock *bb = BasicBlock::Create(m->getContext(), "entry", fn); // From lli: // Should be an array of '{ int, void ()* }' structs. The first value is @@ -174,7 +174,7 @@ static Function *getStubFunctionForCtorList(Module *m, } } - ReturnInst::Create(getGlobalContext(), bb); + ReturnInst::Create(m->getContext(), bb); return fn; } @@ -241,11 +241,13 @@ void KModule::addInternalFunction(const char* functionName){ void KModule::prepare(const Interpreter::ModuleOptions &opts, InterpreterHandler *ih) { + LLVMContext &ctx = module->getContext(); + if (!MergeAtExit.empty()) { Function *mergeFn = module->getFunction("klee_merge"); if (!mergeFn) { LLVM_TYPE_Q llvm::FunctionType *Ty = - FunctionType::get(Type::getVoidTy(getGlobalContext()), + FunctionType::get(Type::getVoidTy(ctx), std::vector<LLVM_TYPE_Q Type*>(), false); mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage, "klee_merge", @@ -264,16 +266,16 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, name.c_str()); } - BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f); + BasicBlock *exit = BasicBlock::Create(ctx, "exit", f); PHINode *result = 0; - if (f->getReturnType() != Type::getVoidTy(getGlobalContext())) + if (f->getReturnType() != Type::getVoidTy(ctx)) #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) result = PHINode::Create(f->getReturnType(), 0, "retval", exit); #else result = PHINode::Create(f->getReturnType(), "retval", exit); #endif CallInst::Create(mergeFn, "", exit); - ReturnInst::Create(getGlobalContext(), result, exit); + ReturnInst::Create(ctx, result, exit); llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n"; for (llvm::Function::iterator bbit = f->begin(), bbie = f->end(); @@ -317,19 +319,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. - LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext()); + LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(ctx); forceImport(module, "memcpy", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), - targetData->getIntPtrType(getGlobalContext()), (Type*) 0); + targetData->getIntPtrType(ctx), (Type*) 0); forceImport(module, "memmove", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), - targetData->getIntPtrType(getGlobalContext()), (Type*) 0); + targetData->getIntPtrType(ctx), (Type*) 0); forceImport(module, "memset", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), - Type::getInt32Ty(getGlobalContext()), - targetData->getIntPtrType(getGlobalContext()), (Type*) 0); + Type::getInt32Ty(ctx), + targetData->getIntPtrType(ctx), (Type*) 0); #endif // FIXME: Missing force import for various math functions. |