33 #define DEBUG_TYPE "inline" 40 std::function<AssumptionCache &(Function &)> GetAssumptionCache =
50 if (!
F.isDeclaration() &&
F.hasFnAttribute(Attribute::AlwaysInline) &&
54 for (
User *U :
F.users())
56 if (CS.getCalledFunction() == &
F)
81 M.getFunctionList().erase(F);
82 InlinedFunctions.
erase(NonComdatBegin, InlinedFunctions.
end());
84 if (!InlinedFunctions.
empty()) {
90 M.getFunctionList().erase(F);
109 AlwaysInlinerLegacyPass(
bool InsertLifetime)
115 bool runOnSCC(
CallGraphSCC &SCC)
override {
return inlineCalls(SCC); }
122 bool doFinalization(
CallGraph &CG)
override {
123 return removeDeadFunctions(CG,
true);
130 "Inliner for always_inline functions",
false,
false)
139 return new AlwaysInlinerLegacyPass(InsertLifetime);
166 if (!CS.
hasFnAttr(Attribute::AlwaysInline))
Pass interface - Implemented by all 'passes'.
InlineCost getInlineCost(CallBase &Call, const InlineParams &Params, TargetTransformInfo &CalleeTTI, std::function< AssumptionCache &(Function &)> &GetAssumptionCache, Optional< function_ref< BlockFrequencyInfo &(Function &)>> GetBFI, ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE=nullptr)
Get an InlineCost object representing the cost of inlining this callsite.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
INITIALIZE_PASS_BEGIN(AlwaysInlinerLegacyPass, "always-inline", "Inliner for always_inline functions", false, false) INITIALIZE_PASS_END(AlwaysInlinerLegacyPass
void push_back(const T &Elt)
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of @llvm.assume calls within a function.
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
Represents the cost of inlining a function.
#define INITIALIZE_PASS_DEPENDENCY(depName)
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
This class contains all of the helper code which is used to perform the inlining operations that do n...
virtual bool doFinalization(Module &)
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
always Inliner for always_inline functions
bool insert(const value_type &X)
Insert a new element into the SetVector.
auto partition(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly...
static InlineCost getAlways(const char *Reason)
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
A set of analyses that are preserved following a run of a transformation pass.
The ModulePass which wraps up a CallGraph and the logic to build it.
InlineResult isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
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, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true)
This function inlines the called function into the basic block of the caller.
void initializeAlwaysInlinerLegacyPassPass(PassRegistry &)
iterator erase(const_iterator CI)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Provides passes to inlining "always_inline" functions.
A function analysis which provides an AssumptionCache.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
A SetVector that performs no allocations if smaller than a certain size.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
void clear()
Completely clear the SetVector.
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
amdgpu Simplify well known AMD library false FunctionCallee Callee
void filterDeadComdatFunctions(Module &M, SmallVectorImpl< Function *> &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive...
The basic data container for the call graph of a Module of IR.
static InlineCost getNever(const char *Reason)
LLVM_NODISCARD bool empty() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
A container for analyses that lazily runs them and caches their results.
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...