diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp --- a/llvm/lib/Analysis/CGSCCPassManager.cpp +++ b/llvm/lib/Analysis/CGSCCPassManager.cpp @@ -15,7 +15,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Analysis/LazyCallGraph.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/Instruction.h" @@ -456,8 +455,8 @@ // because if there is a single call edge, whether there are ref edges is // irrelevant. for (Instruction &I : instructions(F)) - if (auto CS = CallSite(&I)) - if (Function *Callee = CS.getCalledFunction()) + if (auto *CB = dyn_cast(&I)) + if (Function *Callee = CB->getCalledFunction()) if (Visited.insert(Callee).second && !Callee->isDeclaration()) { Node &CalleeN = *G.lookup(*Callee); Edge *E = N->lookup(CalleeN); diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -17,7 +17,6 @@ #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/VectorUtils.h" #include "llvm/Config/llvm-config.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Instruction.h" @@ -100,8 +99,8 @@ // safety of optimizing a direct call edge. for (BasicBlock &BB : *F) for (Instruction &I : BB) { - if (auto CS = CallSite(&I)) - if (Function *Callee = CS.getCalledFunction()) + if (auto *CB = dyn_cast(&I)) + if (Function *Callee = CB->getCalledFunction()) if (!Callee->isDeclaration()) if (Callees.insert(Callee).second) { Visited.insert(Callee); diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -480,8 +480,8 @@ return false; for (Instruction &I : *BB) - if (auto CS = CallSite(&I)) - if (CS.cannotDuplicate()) + if (auto *CB = dyn_cast(&I)) + if (CB->cannotDuplicate()) return false; } return true; diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -86,7 +86,6 @@ #include "llvm/IR/Argument.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/ConstantRange.h" #include "llvm/IR/Constants.h" @@ -6579,7 +6578,7 @@ case Instruction::Call: case Instruction::Invoke: - if (Value *RV = CallSite(U).getReturnedArgOperand()) + if (Value *RV = cast(U)->getReturnedArgOperand()) return getSCEV(RV); break; } diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -27,7 +27,6 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/BasicBlock.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Comdat.h" #include "llvm/IR/Constant.h" @@ -5312,7 +5311,7 @@ for (auto UI = I.first->materialized_user_begin(), UE = I.first->user_end(); UI != UE;) // Don't expect any other users than call sites - CallSite(*UI++).setCalledFunction(I.second); + cast(*UI++)->setCalledFunction(I.second); // Finish fn->subprogram upgrade for materialized functions. if (DISubprogram *SP = MDLoader->lookupSubprogramForFunction(F)) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp @@ -21,7 +21,6 @@ #include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/CallGraphSCCPass.h" #include "llvm/CodeGen/TargetPassConfig.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" @@ -287,14 +286,13 @@ for (BasicBlock &BB : F) { for (Instruction &I : BB) { - CallSite CS(&I); - if (CS) { - const Function *Callee - = dyn_cast(CS.getCalledValue()->stripPointerCasts()); + if (auto *CB = dyn_cast(&I)) { + const Function *Callee = + dyn_cast(CB->getCalledValue()->stripPointerCasts()); // TODO: Do something with indirect calls. if (!Callee) { - if (!CS.isInlineAsm()) + if (!CB->isInlineAsm()) HaveCall = true; continue; } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp @@ -220,9 +220,8 @@ ++FI.InstCount; continue; } - CallSite CS(const_cast(&I)); - if (CS) { - Function *Callee = CS.getCalledFunction(); + if (auto *CB = dyn_cast(&I)) { + Function *Callee = CB->getCalledFunction(); if (!Callee || Callee->isDeclaration()) { ++FI.InstCount; continue; diff --git a/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp b/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp --- a/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp +++ b/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp @@ -109,7 +109,6 @@ FunctionCallee FCache = M.getOrInsertFunction( MASSVEntryName, Func.getFunctionType(), Func.getAttributes()); - CallSite CS(CI); CI->setCalledFunction(FCache); return true; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp @@ -23,7 +23,6 @@ //===----------------------------------------------------------------------===// #include "WebAssembly.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" @@ -73,11 +72,11 @@ else if (auto *A = dyn_cast(U.getUser())) findUses(A, F, Uses, ConstantBCs); else if (U.get()->getType() != F.getType()) { - CallSite CS(U.getUser()); - if (!CS) + CallBase *CB = dyn_cast(U.getUser()); + if (!CB) // Skip uses that aren't immediately called continue; - Value *Callee = CS.getCalledValue(); + Value *Callee = CB->getCalledValue(); if (Callee != V) // Skip calls where the function isn't the callee continue; diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp --- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp @@ -32,7 +32,6 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" @@ -1094,7 +1093,7 @@ if (isa(I)) continue; - if (CallSite(I)) + if (isa(I)) return true; } return false; @@ -1164,13 +1163,11 @@ Prev = Pred->getTerminator(); } - CallSite CS{Prev}; - if (!CS) + CallBase *CB = dyn_cast(Prev); + if (!CB) return false; - auto *CallInstr = CS.getInstruction(); - - auto *Callee = CS.getCalledValue()->stripPointerCasts(); + auto *Callee = CB->getCalledValue()->stripPointerCasts(); // See if the callsite is for resumption or destruction of the coroutine. auto *SubFn = dyn_cast(Callee); @@ -1185,7 +1182,7 @@ // calls in between Save and CallInstr. They can potenitally resume the // coroutine rendering this optimization unsafe. auto *Save = Suspend->getCoroSave(); - if (hasCallsBetween(Save, CallInstr)) + if (hasCallsBetween(Save, CB)) return false; // Replace llvm.coro.suspend with the value that results in resumption over @@ -1195,13 +1192,13 @@ Save->eraseFromParent(); // No longer need a call to coro.resume or coro.destroy. - if (auto *Invoke = dyn_cast(CallInstr)) { + if (auto *Invoke = dyn_cast(CB)) { BranchInst::Create(Invoke->getNormalDest(), Invoke); } - // Grab the CalledValue from CS before erasing the CallInstr. - auto *CalledValue = CS.getCalledValue(); - CallInstr->eraseFromParent(); + // Grab the CalledValue from CB before erasing the CallInstr. + auto *CalledValue = CB->getCalledValue(); + CB->eraseFromParent(); // If no more users remove it. Usually it is a bitcast of SubFn. if (CalledValue != SubFn && CalledValue->user_empty()) diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -720,17 +720,17 @@ Changed = true; } } else if (isa(I) || isa(I)) { - CallSite CS(I); - if (CS.getCalledValue() == V) { + CallBase *CB = cast(I); + if (CB->getCalledValue() == V) { // Calling through the pointer! Turn into a direct call, but be careful // that the pointer is not also being passed as an argument. - CS.setCalledFunction(NewV); + CB->setCalledOperand(NewV); Changed = true; bool PassedAsArg = false; - for (unsigned i = 0, e = CS.arg_size(); i != e; ++i) - if (CS.getArgument(i) == V) { + for (unsigned i = 0, e = CB->arg_size(); i != e; ++i) + if (CB->getArgOperand(i) == V) { PassedAsArg = true; - CS.setArgument(i, NewV); + CB->setArgOperand(i, NewV); } if (PassedAsArg) { @@ -2131,8 +2131,7 @@ for (User *U : F->users()) { if (isa(U)) continue; - CallSite CS(cast(U)); - CS.setCallingConv(CallingConv::Fast); + cast(U)->setCallingConv(CallingConv::Fast); } } @@ -2149,8 +2148,8 @@ for (User *U : F->users()) { if (isa(U)) continue; - CallSite CS(cast(U)); - CS.setAttributes(StripAttr(F->getContext(), CS.getAttributes(), A)); + CallBase *CB = cast(U); + CB->setAttributes(StripAttr(F->getContext(), CB->getAttributes(), A)); } } @@ -2230,8 +2229,7 @@ for (User *U : F->users()) { if (isa(U)) continue; - CallSite CS(cast(U)); - CS.setCallingConv(CallingConv::Cold); + cast(U)->setCallingConv(CallingConv::Cold); } } diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -39,7 +39,6 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Dominators.h" @@ -110,8 +109,8 @@ // The block is cold if it calls/invokes a cold function. However, do not // mark sanitizer traps as cold. for (Instruction &I : BB) - if (auto CS = CallSite(&I)) - if (CS.hasFnAttr(Attribute::Cold) && !CS->getMetadata("nosanitize")) + if (auto *CB = dyn_cast(&I)) + if (CB->hasFnAttr(Attribute::Cold) && !CB->getMetadata("nosanitize")) return true; // The block is cold if it has an unreachable terminator, unless it's @@ -325,11 +324,10 @@ if (Function *OutF = CE.extractCodeRegion(CEAC)) { User *U = *OutF->user_begin(); CallInst *CI = cast(U); - CallSite CS(CI); NumColdRegionsOutlined++; if (TTI.useColdCCForColdCall(*OutF)) { OutF->setCallingConv(CallingConv::Cold); - CS.setCallingConv(CallingConv::Cold); + CI->setCallingConv(CallingConv::Cold); } CI->setIsNoInline();