29#define DEBUG_TYPE "inline"
43 if (
F.isPresplitCoroutine())
51 for (
User *U :
F.users())
52 if (
auto *CB = dyn_cast<CallBase>(U))
53 if (CB->getCalledFunction() == &
F &&
54 CB->hasFnAttr(Attribute::AlwaysInline) &&
55 !CB->getAttributes().hasFnAttr(Attribute::NoInline))
65 GetBFI ? &GetBFI(*Caller) :
nullptr,
66 GetBFI ? &GetBFI(
F) :
nullptr);
69 &GetAAR(
F), InsertLifetime);
73 <<
"'" <<
ore::NV(
"Callee", &
F) <<
"' is not inlined into '"
81 ORE, DLoc,
Block,
F, *Caller,
88 F.removeDeadConstantUsers();
89 if (
F.hasFnAttribute(Attribute::AlwaysInline) &&
F.isDefTriviallyDead()) {
95 M.getFunctionList().erase(
F);
101 if (!InlinedComdatFunctions.
empty()) {
106 for (
Function *
F : InlinedComdatFunctions) {
107 M.getFunctionList().erase(
F);
115struct AlwaysInlinerLegacyPass :
public ModulePass {
118 AlwaysInlinerLegacyPass()
119 : AlwaysInlinerLegacyPass(
true) {}
121 AlwaysInlinerLegacyPass(
bool InsertLifetime)
129 auto &PSI = getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
131 return getAnalysis<AAResultsWrapperPass>(
F).getAAResults();
134 return getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F);
137 return AlwaysInlineImpl(M, InsertLifetime, PSI, GetAssumptionCache, GetAAR,
152char AlwaysInlinerLegacyPass::ID = 0;
154 "Inliner for always_inline functions",
false,
false)
162 return new AlwaysInlinerLegacyPass(InsertLifetime);
180 bool Changed = AlwaysInlineImpl(M, InsertLifetime, PSI, GetAssumptionCache,
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
always Inliner for always_inline functions
Provides passes to inlining "always_inline" functions.
Module.h This file contains the declarations for the Module class.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file implements a set that has insertion order iteration characteristics.
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
A function analysis which provides an AssumptionCache.
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static InlineCost getAlways(const char *Reason, std::optional< CostBenefitPair > CostBenefit=std::nullopt)
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
InlineResult is basically true or false.
const char * getFailureReason() const
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Analysis providing profile information.
void clear()
Completely clear the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An efficient, type-erasing, non-owning reference to a callable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
InlineResult isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
void emitInlinedIntoBasedOnCost(OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, const Function &Callee, const Function &Caller, const InlineCost &IC, bool ForProfileContext=false, const char *PassName=nullptr)
Emit ORE message based in cost (default heuristic).
Pass * createAlwaysInlinerLegacyPass(bool InsertLifetime=true)
Create a legacy pass manager instance of a pass to inline and remove functions marked as "always_inli...
InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, Function *ForwardVarArgsTo=nullptr)
This function inlines the called function into the basic block of the caller.
void filterDeadComdatFunctions(SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.
void initializeAlwaysInlinerLegacyPassPass(PassRegistry &)