36 #define DEBUG_TYPE "inline"
44 if (!
F.isDeclaration() &&
F.hasFnAttribute(Attribute::AlwaysInline) &&
48 for (
User *U :
F.users())
50 if (CS.getCalledFunction() == &
F)
74 M.getFunctionList().erase(F);
75 InlinedFunctions.
erase(NonComdatBegin, InlinedFunctions.
end());
77 if (!InlinedFunctions.
empty()) {
83 M.getFunctionList().erase(F);
102 AlwaysInlinerLegacyPass(
bool InsertLifetime)
108 bool runOnSCC(
CallGraphSCC &SCC)
override {
return inlineCalls(SCC); }
115 bool doFinalization(
CallGraph &CG)
override {
116 return removeDeadFunctions(CG,
true);
123 "Inliner for always_inline functions",
false,
false)
132 return new AlwaysInlinerLegacyPass(InsertLifetime);
Pass interface - Implemented by all 'passes'.
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
void push_back(const T &Elt)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
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
An immutable pass that tracks lazily created AssumptionCache objects.
InlineFunctionInfo - This class captures the data input to the InlineFunction call, and records the auxiliary results produced by it.
Represents the cost of inlining a function.
bool InlineFunction(CallInst *C, InlineFunctionInfo &IFI, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true)
InlineFunction - This function inlines the called function into the basic block of the caller...
#define INITIALIZE_PASS_DEPENDENCY(depName)
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
InlineCost getInlineCost(CallSite CS, const InlineParams &Params, TargetTransformInfo &CalleeTTI, std::function< AssumptionCache &(Function &)> &GetAssumptionCache, ProfileSummaryInfo *PSI)
Get an InlineCost object representing the cost of inlining this callsite.
This class contains all of the helper code which is used to perform the inlining operations that do n...
bool isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
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
void filterDeadComdatFunctions(Module &M, SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive...
LLVM_NODISCARD bool empty() const
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
bool insert(const value_type &X)
Insert a new element into the SetVector.
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.
always Inliner for always_inline false
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
static InlineCost getNever()
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
Pass * createAlwaysInlinerLegacyPass(bool InsertLifetime=true)
Create a legacy pass manager instance of a pass to inline and remove functions marked as "always_inli...
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
void initializeAlwaysInlinerLegacyPassPass(PassRegistry &)
iterator erase(const_iterator CI)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Provides passes to inlining "always_inline" functions.
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.
The basic data container for the call graph of a Module of IR.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
auto partition(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly...
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
A container for analyses that lazily runs them and caches their results.
static InlineCost getAlways()