MLIR  15.0.0git
Macros | Functions
Inliner.cpp File Reference
#include "PassDetail.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 "mlir/Transforms/Passes.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/Support/Debug.h"
+ Include dependency graph for Inliner.cpp:

Go to the source code of this file.

Macros

#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 28 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 321 of file Inliner.cpp.

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

Referenced by inlineCallsInSCC(), and inlineHistoryIncludes().

◆ defaultInlinerOptPipeline()

static void defaultInlinerOptPipeline ( OpPassManager pm)
static

This function implements the default inliner optimization pipeline.

Definition at line 33 of file Inliner.cpp.

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

Referenced by mlir::createInlinerPass(), and inlineCallsInSCC().

◆ getNodeName()

static std::string getNodeName ( CallOpInterface  op)
static

Definition at line 370 of file Inliner.cpp.

References mlir::debugString().

Referenced by inlineCallsInSCC().

◆ inlineCallsInSCC()

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

◆ 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 379 of file Inliner.cpp.

References collectCallOps(), mlir::Operation::erase(), mlir::CallGraphNode::getCallableRegion(), mlir::Region::getParentOp(), mlir::Region::getParentRegion(), and mlir::CallGraph::lookupNode().

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 288 of file Inliner.cpp.

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

Referenced by inlineCallsInSCC().

◆ shouldInline()

static bool shouldInline ( ResolvedCall &  resolvedCall)
static

Returns true if the given call should be inlined.

Definition at line 441 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 42 of file Inliner.cpp.

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