diff options
author | Lukas Zaoral <lzaoral@redhat.com> | 2020-09-12 11:02:29 +0200 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-09-26 21:31:49 +0100 |
commit | 3983b23eac93b0e6f28ffba4b626401c5280c10f (patch) | |
tree | 5589ff2a11f892cb4911c235e7856ef965cc4059 /lib/Module | |
parent | e9aaebb43b5789692377e7b367813e8b3b728484 (diff) | |
download | klee-3983b23eac93b0e6f28ffba4b626401c5280c10f.tar.gz |
Replace llvm::CallSite with llvm::CallBase on LLVM 8+
This is in preparation for LLVM 11 as the llvm:CallSite class has been removed.
Diffstat (limited to 'lib/Module')
-rw-r--r-- | lib/Module/KModule.cpp | 10 | ||||
-rw-r--r-- | lib/Module/ModuleUtil.cpp | 17 |
2 files changed, 22 insertions, 5 deletions
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 04c8f09f..b16be68a 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -27,7 +27,9 @@ #else #include "llvm/Bitcode/ReaderWriter.h" #endif +#if LLVM_VERSION_CODE < LLVM_VERSION(8, 0) #include "llvm/IR/CallSite.h" +#endif #include "llvm/IR/DataLayout.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" @@ -471,13 +473,17 @@ KFunction::KFunction(llvm::Function *_function, ki->dest = registerMap[inst]; if (isa<CallInst>(it) || isa<InvokeInst>(it)) { - CallSite cs(inst); +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + const CallBase &cs = cast<CallBase>(*inst); +#else + const CallSite cs(inst); +#endif unsigned numArgs = cs.arg_size(); ki->operands = new int[numArgs+1]; ki->operands[0] = getOperandNum(cs.getCalledValue(), registerMap, km, ki); for (unsigned j=0; j<numArgs; j++) { - Value *v = cs.getArgument(j); + Value *v = cs.getArgOperand(j); ki->operands[j+1] = getOperandNum(v, registerMap, km, ki); } } else { diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index f369258a..bce6de97 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -251,7 +251,13 @@ klee::linkModules(std::vector<std::unique_ptr<llvm::Module>> &modules, return composite; } -Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { +Function *klee::getDirectCallTarget( +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + const CallBase &cs, +#else + const CallSite &cs, +#endif + bool moduleIsFullyLinked) { Value *v = cs.getCalledValue(); bool viaConstantExpr = false; // Walk through aliases and bitcasts to try to find @@ -287,11 +293,16 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { static bool valueIsOnlyCalled(const Value *v) { for (auto user : v->users()) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + // Make sure the instruction is a call or invoke. + if (const auto *cs_ptr = dyn_cast<CallBase>(user)) { + const CallBase &cs = *cs_ptr; +#else if (const auto *instr = dyn_cast<Instruction>(user)) { // Make sure the instruction is a call or invoke. - CallSite cs(const_cast<Instruction *>(instr)); + const CallSite cs(const_cast<Instruction *>(instr)); if (!cs) return false; - +#endif // Make sure that the value is only the target of this call and // not an argument. if (cs.hasArgument(v)) |