Jlm
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
jlm::llvm::FunctionInlining Class Referencefinal

Performs function inlining on functions that are determined to be good candidates, such as private functions that are only called from a single call site. More...

#include <inlining.hpp>

Inheritance diagram for jlm::llvm::FunctionInlining:
Inheritance graph
[legend]
Collaboration diagram for jlm::llvm::FunctionInlining:
Collaboration graph
[legend]

Classes

struct  Context
 
class  Statistics
 

Public Member Functions

 ~FunctionInlining () noexcept override
 
 FunctionInlining ()
 
 FunctionInlining (const FunctionInlining &)=delete
 
FunctionInliningoperator= (const FunctionInlining &)=delete
 
void Run (rvsdg::RvsdgModule &module, util::StatisticsCollector &statisticsCollector) override
 Perform RVSDG transformation. More...
 
- Public Member Functions inherited from jlm::rvsdg::Transformation
virtual ~Transformation () noexcept
 
 Transformation (std::string_view Name)
 
const std::string_view & GetName () const noexcept
 
void Run (RvsdgModule &module)
 Perform RVSDG transformation. More...
 

Static Public Member Functions

static void inlineCall (rvsdg::SimpleNode &callNode, const rvsdg::LambdaNode &callee)
 
static bool canBeInlined (const rvsdg::LambdaNode &callee)
 

Private Member Functions

bool shouldInline (rvsdg::SimpleNode &callNode, rvsdg::LambdaNode &caller, rvsdg::LambdaNode &callee)
 
void considerCallForInlining (rvsdg::SimpleNode &callNode, rvsdg::LambdaNode &callerLambda)
 
void visitIntraProceduralRegion (rvsdg::Region &region, rvsdg::LambdaNode &lambda)
 
void visitLambda (rvsdg::LambdaNode &lambda)
 
void visitInterProceduralRegion (rvsdg::Region &region)
 

Static Private Member Functions

static void inlineCall (rvsdg::SimpleNode &callNode, rvsdg::LambdaNode &caller, const rvsdg::LambdaNode &callee)
 
static bool canBeInlined (rvsdg::Region &region, bool topLevelRegion)
 

Private Attributes

std::unique_ptr< Contextcontext_
 

Detailed Description

Performs function inlining on functions that are determined to be good candidates, such as private functions that are only called from a single call site.

Definition at line 24 of file inlining.hpp.

Constructor & Destructor Documentation

◆ ~FunctionInlining()

jlm::llvm::FunctionInlining::~FunctionInlining ( )
overridedefaultnoexcept

◆ FunctionInlining() [1/2]

jlm::llvm::FunctionInlining::FunctionInlining ( )

Definition at line 89 of file inlining.cpp.

◆ FunctionInlining() [2/2]

jlm::llvm::FunctionInlining::FunctionInlining ( const FunctionInlining )
delete

Member Function Documentation

◆ canBeInlined() [1/2]

bool jlm::llvm::FunctionInlining::canBeInlined ( const rvsdg::LambdaNode callee)
static

Determines if there is anything in the function callee that prevents it from being inlined.

Returns
true if nothing disqualifying inlining was found in the region.

Definition at line 395 of file inlining.cpp.

◆ canBeInlined() [2/2]

bool jlm::llvm::FunctionInlining::canBeInlined ( rvsdg::Region region,
bool  topLevelRegion 
)
staticprivate

Determines if there is anything in the region that would prevent a function from being inlined. Recurses into subregions.

Parameters
regionthe region in question
topLevelRegiontrue if the region is the top level region in its lambda node
Returns
true if nothing disqualifying inlining was found in the region.

Definition at line 344 of file inlining.cpp.

◆ considerCallForInlining()

void jlm::llvm::FunctionInlining::considerCallForInlining ( rvsdg::SimpleNode callNode,
rvsdg::LambdaNode callerLambda 
)
private

Determines if the given callNode is a call that can be inlined, and if it should be inlined. If yes, inlining is performed.

Parameters
callNodethe node containing the CallOperation
callerLambdathe lambda containing the call node, a.k.a. the caller

Definition at line 411 of file inlining.cpp.

◆ inlineCall() [1/2]

void jlm::llvm::FunctionInlining::inlineCall ( rvsdg::SimpleNode callNode,
const rvsdg::LambdaNode callee 
)
static

Performs inlining of the given call node, targeting the given callee function

Parameters
callNodethe call to inline
calleethe function being inlined

Definition at line 337 of file inlining.cpp.

◆ inlineCall() [2/2]

void jlm::llvm::FunctionInlining::inlineCall ( rvsdg::SimpleNode callNode,
rvsdg::LambdaNode caller,
const rvsdg::LambdaNode callee 
)
staticprivate

Performs inlining of the given call

Parameters
callNodethe node containing the CallOperation
callerthe lambda node of the caller
calleethe lambda node of the callee

Definition at line 278 of file inlining.cpp.

◆ operator=()

FunctionInlining& jlm::llvm::FunctionInlining::operator= ( const FunctionInlining )
delete

◆ Run()

void jlm::llvm::FunctionInlining::Run ( rvsdg::RvsdgModule module,
util::StatisticsCollector statisticsCollector 
)
overridevirtual

Perform RVSDG transformation.

Note
This method is expected to be called multiple times. An implementation is required to reset the objects' internal state to ensure correct behavior after every invocation.
Parameters
moduleRVSDG module the transformation is performed on.
statisticsCollectorStatistics collector for collecting transformation statistics.

Implements jlm::rvsdg::Transformation.

Definition at line 504 of file inlining.cpp.

◆ shouldInline()

bool jlm::llvm::FunctionInlining::shouldInline ( rvsdg::SimpleNode callNode,
rvsdg::LambdaNode caller,
rvsdg::LambdaNode callee 
)
private

Determines if the given call should be inlined or not.

Parameters
callNodethe node containing the CallOperation
callerthe lambda node of the caller
calleethe lambda node of the callee
Returns

Definition at line 401 of file inlining.cpp.

◆ visitInterProceduralRegion()

void jlm::llvm::FunctionInlining::visitInterProceduralRegion ( rvsdg::Region region)
private

Visits all lambda nodes in the given region, including in subregions. In each visited lambda, inlining transformations are applied if determined to be beneficial.

Parameters
regionthe region in question

Definition at line 486 of file inlining.cpp.

◆ visitIntraProceduralRegion()

void jlm::llvm::FunctionInlining::visitIntraProceduralRegion ( rvsdg::Region region,
rvsdg::LambdaNode lambda 
)
private

Recursively visits all call operations in the region and its subregions, and performs inlining if determined to be beneficial.

Parameters
regionthe region being visited
lambdathe function to which the region belongs

Definition at line 443 of file inlining.cpp.

◆ visitLambda()

void jlm::llvm::FunctionInlining::visitLambda ( rvsdg::LambdaNode lambda)
private

Visits the given function, performing inlining of calls inside it, and storing facts about it that may be relevant when considering inlining calls to the function.

Parameters
lambdathe function in question

Definition at line 467 of file inlining.cpp.

Member Data Documentation

◆ context_

std::unique_ptr<Context> jlm::llvm::FunctionInlining::context_
private

Definition at line 129 of file inlining.hpp.


The documentation for this class was generated from the following files: