From 30336015ff88298f38841efa1e0dd120e71f2f67 Mon Sep 17 00:00:00 2001 From: Lukas Zaoral Date: Thu, 10 Sep 2020 17:14:42 +0200 Subject: llvm11: Use getCalledOperand instead of getCalledValue CallBase::getCalledValue has been deprecated by getCalledOperand since LLVM 8 and has been removed in LLVM 11 See: https://reviews.llvm.org/D78882 --- lib/Core/Executor.cpp | 3 ++- lib/Core/StatsTracker.cpp | 3 ++- lib/Module/KModule.cpp | 5 +++-- lib/Module/ModuleUtil.cpp | 4 ++++ lib/Module/RaiseAsm.cpp | 4 ++++ tools/klee/main.cpp | 4 ++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 333eb563..c0d29272 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -2339,12 +2339,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { #if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) const CallBase &cs = cast(*i); + Value *fp = cs.getCalledOperand(); #else const CallSite cs(i); + Value *fp = cs.getCalledValue(); #endif unsigned numArgs = cs.arg_size(); - Value *fp = cs.getCalledValue(); Function *f = getTargetFunction(fp, state); if (isa(fp)) { diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index a94bad9e..93dfcbfe 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -797,10 +797,11 @@ void StatsTracker::computeReachableUncovered() { if (isa(inst) || isa(inst)) { #if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) const CallBase &cs = cast(*inst); + if (isa(cs.getCalledOperand())) { #else const CallSite cs(inst); -#endif if (isa(cs.getCalledValue())) { +#endif // We can never call through here so assume no targets // (which should be correct anyhow). callTargets.insert(std::make_pair(inst, diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index b16be68a..50bb28bb 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -475,13 +475,14 @@ KFunction::KFunction(llvm::Function *_function, if (isa(it) || isa(it)) { #if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) const CallBase &cs = cast(*inst); + Value *val = cs.getCalledOperand(); #else const CallSite cs(inst); + Value *val = cs.getCalledValue(); #endif unsigned numArgs = cs.arg_size(); ki->operands = new int[numArgs+1]; - ki->operands[0] = getOperandNum(cs.getCalledValue(), registerMap, km, - ki); + ki->operands[0] = getOperandNum(val, registerMap, km, ki); for (unsigned j=0; joperands[j+1] = getOperandNum(v, registerMap, km, ki); diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 7cd66415..2c855261 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -285,7 +285,11 @@ Function *klee::getDirectCallTarget( const CallSite &cs, #endif bool moduleIsFullyLinked) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + Value *v = cs.getCalledOperand(); +#else Value *v = cs.getCalledValue(); +#endif bool viaConstantExpr = false; // Walk through aliases and bitcasts to try to find // the function being called. diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 3de28f4d..ff4c2467 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -48,7 +48,11 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { if (!ci) return false; +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + InlineAsm *ia = dyn_cast(ci->getCalledOperand()); +#else InlineAsm *ia = dyn_cast(ci->getCalledValue()); +#endif if (!ia) return false; diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 874660d7..c1270b46 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -917,7 +917,11 @@ void externalsAndGlobalsCheck(const llvm::Module *m) { for (BasicBlock::const_iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { if (const CallInst *ci = dyn_cast(it)) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + if (isa(ci->getCalledOperand())) { +#else if (isa(ci->getCalledValue())) { +#endif klee_warning_once(&*fnIt, "function \"%s\" has inline asm", fnIt->getName().data()); -- cgit 1.4.1