18#include "llvm/Analysis/CallGraph.h"
19#include "llvm/Analysis/CallGraphSCCPass.h"
20#include "llvm/IR/PassManager.h"
21#include "llvm/Passes/PassBuilder.h"
22#include "llvm/Transforms/IPO/AlwaysInliner.h"
25#define DEBUG_TYPE "polly-scop-inliner"
31class ScopInliner final :
public CallGraphSCCPass {
32 using llvm::Pass::doInitialization;
37 ScopInliner() : CallGraphSCCPass(ID) {}
39 bool doInitialization(CallGraph &CG)
override {
42 "Aborting from ScopInliner because it only makes sense to run with "
43 "-polly-allow-full-function. "
44 "The heurtistic for ScopInliner checks that the full function is a "
45 "Scop, which happens if and only if polly-allow-full-function is "
47 " If not, the entry block is not included in the Scop");
52 bool runOnSCC(CallGraphSCC &SCC)
override {
57 assert(SCC.size() == 1 &&
"found empty SCC");
58 Function *F = (*SCC.begin())->getFunction();
63 if (F->isDeclaration()) {
65 <<
"because it is a declaration.\n");
71 LoopAnalysisManager LAM;
72 FunctionAnalysisManager FAM;
73 CGSCCAnalysisManager CGAM;
74 ModuleAnalysisManager MAM;
76 PB.registerModuleAnalyses(MAM);
77 PB.registerCGSCCAnalyses(CGAM);
78 PB.registerFunctionAnalyses(FAM);
79 PB.registerLoopAnalyses(LAM);
80 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
82 RegionInfo &RI = FAM.getResult<RegionInfoAnalysis>(*F);
85 const bool HasScopAsTopLevelRegion =
89 if (HasScopAsTopLevelRegion) {
91 <<
" has scop as top level region");
92 F->addFnAttr(llvm::Attribute::AlwaysInline);
94 ModulePassManager MPM;
95 MPM.addPass(AlwaysInlinerPass());
97 assert(
M &&
"Function has illegal module");
98 PreservedAnalyses PA = MPM.run(*
M, MAM);
99 if (!PA.areAllPreserved())
103 <<
" does NOT have scop as top level region\n");
109 void getAnalysisUsage(AnalysisUsage &AU)
const override {
110 CallGraphSCCPass::getAnalysisUsage(AU);
117 ScopInliner *pass =
new ScopInliner();
122 ScopInliner,
"polly-scop-inliner",
123 "inline functions based on how much of the function is a scop.",
false,
INITIALIZE_PASS_END(DependenceInfo, "polly-dependences", "Polly - Calculate dependences", false, false) namespace
polly dump Polly Dump Function
polly dump Polly Dump Module
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
polly scop functions based on how much of the function is a scop
INITIALIZE_PASS_BEGIN(ScopInliner, "polly-scop-inliner", "inline functions based on how much of the function is a scop.", false, false) INITIALIZE_PASS_END(ScopInliner
Pass to detect the maximal static control parts (Scops) of a function.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
bool PollyAllowFullFunction
llvm::Pass * createScopInlinerPass()