diff options
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUInline.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUInline.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp index 64d761997b0c..3b5d91133a2f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp @@ -23,7 +23,6 @@ #include "llvm/Analysis/InlineCost.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Analysis/ValueTracking.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" @@ -67,9 +66,9 @@ public: static char ID; // Pass identification, replacement for typeid - unsigned getInlineThreshold(CallSite CS) const; + unsigned getInlineThreshold(CallBase &CB) const; - InlineCost getInlineCost(CallSite CS) override; + InlineCost getInlineCost(CallBase &CB) override; bool runOnSCC(CallGraphSCC &SCC) override; @@ -106,13 +105,13 @@ void AMDGPUInliner::getAnalysisUsage(AnalysisUsage &AU) const { LegacyInlinerBase::getAnalysisUsage(AU); } -unsigned AMDGPUInliner::getInlineThreshold(CallSite CS) const { +unsigned AMDGPUInliner::getInlineThreshold(CallBase &CB) const { int Thres = Params.DefaultThreshold; - Function *Caller = CS.getCaller(); + Function *Caller = CB.getCaller(); // Listen to the inlinehint attribute when it would increase the threshold // and the caller does not need to minimize its size. - Function *Callee = CS.getCalledFunction(); + Function *Callee = CB.getCalledFunction(); bool InlineHint = Callee && !Callee->isDeclaration() && Callee->hasFnAttribute(Attribute::InlineHint); if (InlineHint && Params.HintThreshold && Params.HintThreshold > Thres @@ -129,7 +128,7 @@ unsigned AMDGPUInliner::getInlineThreshold(CallSite CS) const { // Increase the inline threshold to allow inliniting in this case. uint64_t AllocaSize = 0; SmallPtrSet<const AllocaInst *, 8> AIVisited; - for (Value *PtrArg : CS.args()) { + for (Value *PtrArg : CB.args()) { PointerType *Ty = dyn_cast<PointerType>(PtrArg->getType()); if (!Ty || (Ty->getAddressSpace() != AMDGPUAS::PRIVATE_ADDRESS && Ty->getAddressSpace() != AMDGPUAS::FLAT_ADDRESS)) @@ -156,8 +155,8 @@ unsigned AMDGPUInliner::getInlineThreshold(CallSite CS) const { // Check if call is just a wrapper around another call. // In this case we only have call and ret instructions. -static bool isWrapperOnlyCall(CallSite CS) { - Function *Callee = CS.getCalledFunction(); +static bool isWrapperOnlyCall(CallBase &CB) { + Function *Callee = CB.getCalledFunction(); if (!Callee || Callee->size() != 1) return false; const BasicBlock &BB = Callee->getEntryBlock(); @@ -174,32 +173,32 @@ static bool isWrapperOnlyCall(CallSite CS) { return false; } -InlineCost AMDGPUInliner::getInlineCost(CallSite CS) { - Function *Callee = CS.getCalledFunction(); - Function *Caller = CS.getCaller(); +InlineCost AMDGPUInliner::getInlineCost(CallBase &CB) { + Function *Callee = CB.getCalledFunction(); + Function *Caller = CB.getCaller(); if (!Callee || Callee->isDeclaration()) return llvm::InlineCost::getNever("undefined callee"); - if (CS.isNoInline()) + if (CB.isNoInline()) return llvm::InlineCost::getNever("noinline"); TargetTransformInfo &TTI = TTIWP->getTTI(*Callee); if (!TTI.areInlineCompatible(Caller, Callee)) return llvm::InlineCost::getNever("incompatible"); - if (CS.hasFnAttr(Attribute::AlwaysInline)) { + if (CB.hasFnAttr(Attribute::AlwaysInline)) { auto IsViable = isInlineViable(*Callee); - if (IsViable) + if (IsViable.isSuccess()) return llvm::InlineCost::getAlways("alwaysinline viable"); - return llvm::InlineCost::getNever(IsViable.message); + return llvm::InlineCost::getNever(IsViable.getFailureReason()); } - if (isWrapperOnlyCall(CS)) + if (isWrapperOnlyCall(CB)) return llvm::InlineCost::getAlways("wrapper-only call"); InlineParams LocalParams = Params; - LocalParams.DefaultThreshold = (int)getInlineThreshold(CS); + LocalParams.DefaultThreshold = (int)getInlineThreshold(CB); bool RemarksEnabled = false; const auto &BBs = Caller->getBasicBlockList(); if (!BBs.empty()) { @@ -209,14 +208,13 @@ InlineCost AMDGPUInliner::getInlineCost(CallSite CS) { } OptimizationRemarkEmitter ORE(Caller); - std::function<AssumptionCache &(Function &)> GetAssumptionCache = - [this](Function &F) -> AssumptionCache & { + auto GetAssumptionCache = [this](Function &F) -> AssumptionCache & { return ACT->getAssumptionCache(F); }; - auto IC = llvm::getInlineCost(cast<CallBase>(*CS.getInstruction()), Callee, - LocalParams, TTI, GetAssumptionCache, None, PSI, - RemarksEnabled ? &ORE : nullptr); + auto IC = llvm::getInlineCost(CB, Callee, LocalParams, TTI, + GetAssumptionCache, GetTLI, nullptr, PSI, + RemarksEnabled ? &ORE : nullptr); if (IC && !IC.isAlways() && !Callee->hasFnAttribute(Attribute::InlineHint)) { // Single BB does not increase total BB amount, thus subtract 1 |