forked from OSchip/llvm-project
[llvm][NFC][CallSite] Remove Implementation uses of CallSite
Reviewers: dblaikie, davidxl, craig.topper Subscribers: arsenm, dschuff, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78142
This commit is contained in:
parent
cc220d4031
commit
447e2c3067
|
@ -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 @@ static LazyCallGraph::SCC &updateCGAndAnalysisManagerForPass(
|
|||
// 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<CallBase>(&I))
|
||||
if (Function *Callee = CB->getCalledFunction())
|
||||
if (Visited.insert(Callee).second && !Callee->isDeclaration()) {
|
||||
Node &CalleeN = *G.lookup(*Callee);
|
||||
Edge *E = N->lookup(CalleeN);
|
||||
|
|
|
@ -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 @@ LazyCallGraph::EdgeSequence &LazyCallGraph::Node::populateSlow() {
|
|||
// 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<CallBase>(&I))
|
||||
if (Function *Callee = CB->getCalledFunction())
|
||||
if (!Callee->isDeclaration())
|
||||
if (Callees.insert(Callee).second) {
|
||||
Visited.insert(Callee);
|
||||
|
|
|
@ -480,8 +480,8 @@ bool Loop::isSafeToClone() const {
|
|||
return false;
|
||||
|
||||
for (Instruction &I : *BB)
|
||||
if (auto CS = CallSite(&I))
|
||||
if (CS.cannotDuplicate())
|
||||
if (auto *CB = dyn_cast<CallBase>(&I))
|
||||
if (CB->cannotDuplicate())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
|||
|
||||
case Instruction::Call:
|
||||
case Instruction::Invoke:
|
||||
if (Value *RV = CallSite(U).getReturnedArgOperand())
|
||||
if (Value *RV = cast<CallBase>(U)->getReturnedArgOperand())
|
||||
return getSCEV(RV);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
|
|||
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<CallBase>(*UI++)->setCalledFunction(I.second);
|
||||
|
||||
// Finish fn->subprogram upgrade for materialized functions.
|
||||
if (DISubprogram *SP = MDLoader->lookupSubprogramForFunction(F))
|
||||
|
|
|
@ -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 @@ bool AMDGPUAnnotateKernelFeatures::addFeatureAttributes(Function &F) {
|
|||
|
||||
for (BasicBlock &BB : F) {
|
||||
for (Instruction &I : BB) {
|
||||
CallSite CS(&I);
|
||||
if (CS) {
|
||||
const Function *Callee
|
||||
= dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());
|
||||
if (auto *CB = dyn_cast<CallBase>(&I)) {
|
||||
const Function *Callee =
|
||||
dyn_cast<Function>(CB->getCalledValue()->stripPointerCasts());
|
||||
|
||||
// TODO: Do something with indirect calls.
|
||||
if (!Callee) {
|
||||
if (!CS.isInlineAsm())
|
||||
if (!CB->isInlineAsm())
|
||||
HaveCall = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -220,9 +220,8 @@ AMDGPUPerfHintAnalysis::FuncInfo *AMDGPUPerfHint::visit(const Function &F) {
|
|||
++FI.InstCount;
|
||||
continue;
|
||||
}
|
||||
CallSite CS(const_cast<Instruction *>(&I));
|
||||
if (CS) {
|
||||
Function *Callee = CS.getCalledFunction();
|
||||
if (auto *CB = dyn_cast<CallBase>(&I)) {
|
||||
Function *Callee = CB->getCalledFunction();
|
||||
if (!Callee || Callee->isDeclaration()) {
|
||||
++FI.InstCount;
|
||||
continue;
|
||||
|
|
|
@ -109,7 +109,6 @@ bool PPCLowerMASSVEntries::lowerMASSVCall(CallInst *CI, Function &Func,
|
|||
FunctionCallee FCache = M.getOrInsertFunction(
|
||||
MASSVEntryName, Func.getFunctionType(), Func.getAttributes());
|
||||
|
||||
CallSite CS(CI);
|
||||
CI->setCalledFunction(FCache);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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 @@ static void findUses(Value *V, Function &F,
|
|||
else if (auto *A = dyn_cast<GlobalAlias>(U.getUser()))
|
||||
findUses(A, F, Uses, ConstantBCs);
|
||||
else if (U.get()->getType() != F.getType()) {
|
||||
CallSite CS(U.getUser());
|
||||
if (!CS)
|
||||
CallBase *CB = dyn_cast<CallBase>(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;
|
||||
|
|
|
@ -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 @@ static bool hasCallsInBlockBetween(Instruction *From, Instruction *To) {
|
|||
if (isa<IntrinsicInst>(I))
|
||||
continue;
|
||||
|
||||
if (CallSite(I))
|
||||
if (isa<CallBase>(I))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1164,13 +1163,11 @@ static bool simplifySuspendPoint(CoroSuspendInst *Suspend,
|
|||
Prev = Pred->getTerminator();
|
||||
}
|
||||
|
||||
CallSite CS{Prev};
|
||||
if (!CS)
|
||||
CallBase *CB = dyn_cast<CallBase>(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<CoroSubFnInst>(Callee);
|
||||
|
@ -1185,7 +1182,7 @@ static bool simplifySuspendPoint(CoroSuspendInst *Suspend,
|
|||
// 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 @@ static bool simplifySuspendPoint(CoroSuspendInst *Suspend,
|
|||
Save->eraseFromParent();
|
||||
|
||||
// No longer need a call to coro.resume or coro.destroy.
|
||||
if (auto *Invoke = dyn_cast<InvokeInst>(CallInstr)) {
|
||||
if (auto *Invoke = dyn_cast<InvokeInst>(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())
|
||||
|
|
|
@ -720,17 +720,17 @@ static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV) {
|
|||
Changed = true;
|
||||
}
|
||||
} else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
|
||||
CallSite CS(I);
|
||||
if (CS.getCalledValue() == V) {
|
||||
CallBase *CB = cast<CallBase>(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 @@ static void ChangeCalleesToFastCall(Function *F) {
|
|||
for (User *U : F->users()) {
|
||||
if (isa<BlockAddress>(U))
|
||||
continue;
|
||||
CallSite CS(cast<Instruction>(U));
|
||||
CS.setCallingConv(CallingConv::Fast);
|
||||
cast<CallBase>(U)->setCallingConv(CallingConv::Fast);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2149,8 +2148,8 @@ static void RemoveAttribute(Function *F, Attribute::AttrKind A) {
|
|||
for (User *U : F->users()) {
|
||||
if (isa<BlockAddress>(U))
|
||||
continue;
|
||||
CallSite CS(cast<Instruction>(U));
|
||||
CS.setAttributes(StripAttr(F->getContext(), CS.getAttributes(), A));
|
||||
CallBase *CB = cast<CallBase>(U);
|
||||
CB->setAttributes(StripAttr(F->getContext(), CB->getAttributes(), A));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2230,8 +2229,7 @@ static void changeCallSitesToColdCC(Function *F) {
|
|||
for (User *U : F->users()) {
|
||||
if (isa<BlockAddress>(U))
|
||||
continue;
|
||||
CallSite CS(cast<Instruction>(U));
|
||||
CS.setCallingConv(CallingConv::Cold);
|
||||
cast<CallBase>(U)->setCallingConv(CallingConv::Cold);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ bool unlikelyExecuted(BasicBlock &BB) {
|
|||
// 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<CallBase>(&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 @@ Function *HotColdSplitting::extractColdRegion(
|
|||
if (Function *OutF = CE.extractCodeRegion(CEAC)) {
|
||||
User *U = *OutF->user_begin();
|
||||
CallInst *CI = cast<CallInst>(U);
|
||||
CallSite CS(CI);
|
||||
NumColdRegionsOutlined++;
|
||||
if (TTI.useColdCCForColdCall(*OutF)) {
|
||||
OutF->setCallingConv(CallingConv::Cold);
|
||||
CS.setCallingConv(CallingConv::Cold);
|
||||
CI->setCallingConv(CallingConv::Cold);
|
||||
}
|
||||
CI->setIsNoInline();
|
||||
|
||||
|
|
Loading…
Reference in New Issue