diff options
Diffstat (limited to 'llvm/lib/Transforms/IPO/AlwaysInliner.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/AlwaysInliner.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp index 06d1763353f4..53f9512f86f3 100644 --- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp +++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp @@ -16,7 +16,6 @@ #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/InlineCost.h" #include "llvm/Analysis/TargetLibraryInfo.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Instructions.h" @@ -37,30 +36,30 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M, // Add inline assumptions during code generation. FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); - std::function<AssumptionCache &(Function &)> GetAssumptionCache = - [&](Function &F) -> AssumptionCache & { + auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { return FAM.getResult<AssumptionAnalysis>(F); }; - InlineFunctionInfo IFI(/*cg=*/nullptr, &GetAssumptionCache); + InlineFunctionInfo IFI(/*cg=*/nullptr, GetAssumptionCache); - SmallSetVector<CallSite, 16> Calls; + SmallSetVector<CallBase *, 16> Calls; bool Changed = false; SmallVector<Function *, 16> InlinedFunctions; for (Function &F : M) if (!F.isDeclaration() && F.hasFnAttribute(Attribute::AlwaysInline) && - isInlineViable(F)) { + isInlineViable(F).isSuccess()) { Calls.clear(); for (User *U : F.users()) - if (auto CS = CallSite(U)) - if (CS.getCalledFunction() == &F) - Calls.insert(CS); + if (auto *CB = dyn_cast<CallBase>(U)) + if (CB->getCalledFunction() == &F) + Calls.insert(CB); - for (CallSite CS : Calls) + for (CallBase *CB : Calls) // FIXME: We really shouldn't be able to fail to inline at this point! // We should do something to log or check the inline failures here. Changed |= - InlineFunction(CS, IFI, /*CalleeAAR=*/nullptr, InsertLifetime); + InlineFunction(*CB, IFI, /*CalleeAAR=*/nullptr, InsertLifetime) + .isSuccess(); // Remember to try and delete this function afterward. This both avoids // re-walking the rest of the module and avoids dealing with any iterator @@ -116,7 +115,7 @@ public: static char ID; // Pass identification, replacement for typeid - InlineCost getInlineCost(CallSite CS) override; + InlineCost getInlineCost(CallBase &CB) override; using llvm::Pass::doFinalization; bool doFinalization(CallGraph &CG) override { @@ -151,8 +150,8 @@ Pass *llvm::createAlwaysInlinerLegacyPass(bool InsertLifetime) { /// computed here, but as we only expect to do this for relatively few and /// small functions which have the explicit attribute to force inlining, it is /// likely not worth it in practice. -InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallSite CS) { - Function *Callee = CS.getCalledFunction(); +InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallBase &CB) { + Function *Callee = CB.getCalledFunction(); // Only inline direct calls to functions with always-inline attributes // that are viable for inlining. @@ -163,12 +162,12 @@ InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallSite CS) { if (Callee->isDeclaration()) return InlineCost::getNever("no definition"); - if (!CS.hasFnAttr(Attribute::AlwaysInline)) + if (!CB.hasFnAttr(Attribute::AlwaysInline)) return InlineCost::getNever("no alwaysinline attribute"); auto IsViable = isInlineViable(*Callee); - if (!IsViable) - return InlineCost::getNever(IsViable.message); + if (!IsViable.isSuccess()) + return InlineCost::getNever(IsViable.getFailureReason()); return InlineCost::getAlways("always inliner"); } |