MLIR  16.0.0git
Namespaces | Macros | Functions
Inliner.cpp File Reference
#include "mlir/Transforms/Passes.h"
#include "mlir/Analysis/CallGraph.h"
#include "mlir/IR/Threading.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/DebugStringHelper.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/Support/Debug.h"
#include "mlir/Transforms/Passes.h.inc"
+ Include dependency graph for Inliner.cpp:

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_INLINER
 
#define DEBUG_TYPE   "inlining"
 

Functions

static void defaultInlinerOptPipeline (OpPassManager &pm)
 This function implements the default inliner optimization pipeline. More...
 
static void walkReferencedSymbolNodes (Operation *op, CallGraph &cg, SymbolTableCollection &symbolTable, DenseMap< Attribute, CallGraphNode * > &resolvedRefs, function_ref< void(CallGraphNode *, Operation *)> callback)
 Walk all of the used symbol callgraph nodes referenced with the given op. More...
 
static LogicalResult runTransformOnCGSCCs (const CallGraph &cg, function_ref< LogicalResult(CallGraphSCC &)> sccTransformer)
 Run a given transformation over the SCCs of the callgraph in a bottom up traversal. More...
 
static void collectCallOps (iterator_range< Region::iterator > blocks, CallGraphNode *sourceNode, CallGraph &cg, SymbolTableCollection &symbolTable, SmallVectorImpl< ResolvedCall > &calls, bool traverseNestedCGNodes)
 Collect all of the callable operations within the given range of blocks. More...
 
static std::string getNodeName (CallOpInterface op)
 
static bool inlineHistoryIncludes (CallGraphNode *node, Optional< size_t > inlineHistoryID, MutableArrayRef< std::pair< CallGraphNode *, Optional< size_t >>> inlineHistory)
 Return true if the specified inlineHistoryID indicates an inline history that already includes node. More...
 
static bool shouldInline (ResolvedCall &resolvedCall)
 Returns true if the given call should be inlined. More...
 
static LogicalResult inlineCallsInSCC (Inliner &inliner, CGUseList &useList, CallGraphSCC &currentSCC)
 Attempt to inline calls within the given scc. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "inlining"

Definition at line 33 of file Inliner.cpp.

◆ GEN_PASS_DEF_INLINER

#define GEN_PASS_DEF_INLINER

Definition at line 29 of file Inliner.cpp.

Function Documentation

◆ collectCallOps()

static void collectCallOps ( iterator_range< Region::iterator blocks,
CallGraphNode sourceNode,
CallGraph cg,
SymbolTableCollection symbolTable,
SmallVectorImpl< ResolvedCall > &  calls,
bool  traverseNestedCGNodes 
)
static

Collect all of the callable operations within the given range of blocks.

If traverseNestedCGNodes is true, this will also collect call operations inside of nested callgraph nodes.

Definition at line 326 of file Inliner.cpp.

References mlir::Operation::getRegions(), mlir::CallGraphNode::isExternal(), mlir::CallGraph::lookupNode(), and mlir::CallGraph::resolveCallable().

Referenced by inlineCallsInSCC().

◆ defaultInlinerOptPipeline()

static void defaultInlinerOptPipeline ( OpPassManager pm)
static

This function implements the default inliner optimization pipeline.

Definition at line 38 of file Inliner.cpp.

References mlir::OpPassManager::addPass(), and mlir::createCanonicalizerPass().

Referenced by mlir::createInlinerPass().

◆ getNodeName()

static std::string getNodeName ( CallOpInterface  op)
static

Definition at line 375 of file Inliner.cpp.

References mlir::debugString().

Referenced by inlineCallsInSCC().

◆ inlineCallsInSCC()

static LogicalResult inlineCallsInSCC ( Inliner &  inliner,
CGUseList &  useList,
CallGraphSCC &  currentSCC 
)
static

Attempt to inline calls within the given scc.

This function returns success if any calls were inlined, failure otherwise.

Definition at line 464 of file Inliner.cpp.

References collectCallOps(), mlir::failed(), mlir::CallGraphNode::getCallableRegion(), getNodeName(), mlir::Region::getParentOp(), mlir::inlineCall(), inlineHistoryIncludes(), mlir::CallGraphNode::isExternal(), shouldInline(), and mlir::success().

◆ inlineHistoryIncludes()

static bool inlineHistoryIncludes ( CallGraphNode node,
Optional< size_t >  inlineHistoryID,
MutableArrayRef< std::pair< CallGraphNode *, Optional< size_t >>>  inlineHistory 
)
static

Return true if the specified inlineHistoryID indicates an inline history that already includes node.

Definition at line 384 of file Inliner.cpp.

Referenced by inlineCallsInSCC().

◆ runTransformOnCGSCCs()

static LogicalResult runTransformOnCGSCCs ( const CallGraph cg,
function_ref< LogicalResult(CallGraphSCC &)>  sccTransformer 
)
static

Run a given transformation over the SCCs of the callgraph in a bottom up traversal.

Definition at line 293 of file Inliner.cpp.

References mlir::failed(), mlir::failure(), and mlir::success().

◆ shouldInline()

static bool shouldInline ( ResolvedCall &  resolvedCall)
static

Returns true if the given call should be inlined.

Definition at line 446 of file Inliner.cpp.

Referenced by inlineCallsInSCC().

◆ walkReferencedSymbolNodes()

static void walkReferencedSymbolNodes ( Operation op,
CallGraph cg,
SymbolTableCollection symbolTable,
DenseMap< Attribute, CallGraphNode * > &  resolvedRefs,
function_ref< void(CallGraphNode *, Operation *)>  callback 
)
static

Walk all of the used symbol callgraph nodes referenced with the given op.

Definition at line 47 of file Inliner.cpp.

References mlir::Operation::getParentOp(), mlir::SymbolTable::getSymbolUses(), mlir::SymbolTableCollection::lookupNearestSymbolFrom(), and mlir::CallGraph::lookupNode().