18#include "llvm/Analysis/GlobalsModRef.h"
19#include "llvm/Analysis/ProfileSummaryInfo.h"
20#include "llvm/IR/LegacyPassManager.h"
21#include "llvm/Transforms/IPO.h"
22#include "llvm/Transforms/IPO/FunctionAttrs.h"
23#include "llvm/Transforms/InstCombine/InstCombine.h"
24#include "llvm/Transforms/Scalar.h"
25#include "llvm/Transforms/Scalar/EarlyCSE.h"
26#include "llvm/Transforms/Scalar/IndVarSimplify.h"
27#include "llvm/Transforms/Scalar/LoopRotation.h"
28#include "llvm/Transforms/Scalar/Reassociate.h"
29#include "llvm/Transforms/Scalar/SimplifyCFG.h"
30#include "llvm/Transforms/Scalar/TailRecursionElimination.h"
31#include "llvm/Transforms/Utils.h"
32#include "llvm/Transforms/Utils/Mem2Reg.h"
39 cl::desc(
"Run an early inliner pass before Polly"), cl::Hidden,
43 bool UseMemSSA =
true;
44 PM.add(llvm::createPromoteMemoryToRegisterPass());
45 PM.add(llvm::createEarlyCSEPass(UseMemSSA));
46 PM.add(llvm::createInstructionCombiningPass());
47 PM.add(llvm::createCFGSimplificationPass());
48 PM.add(llvm::createTailCallEliminationPass());
49 PM.add(llvm::createCFGSimplificationPass());
50 PM.add(llvm::createReassociatePass());
52 PM.add(llvm::createPromoteMemoryToRegisterPass());
53 PM.add(llvm::createCFGSimplificationPass());
54 PM.add(llvm::createInstructionCombiningPass());
55 PM.add(createBarrierNoopPass());
57 PM.add(llvm::createInstructionCombiningPass());
61static ModuleInlinerWrapperPass
63 InlineParams IP = getInlineParams(200);
64 ModuleInlinerWrapperPass MIWP(IP);
68 MIWP.addModulePass(RequireAnalysisPass<GlobalsAA, Module>());
72 createModuleToFunctionPassAdaptor(InvalidateAnalysisPass<AAManager>()));
76 MIWP.addModulePass(RequireAnalysisPass<ProfileSummaryAnalysis, Module>());
82 CGSCCPassManager &MainCGPipeline = MIWP.getPM();
85 MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
92 llvm::OptimizationLevel Level) {
93 FunctionPassManager FPM;
95 bool UseMemSSA =
true;
96 FPM.addPass(PromotePass());
97 FPM.addPass(EarlyCSEPass(UseMemSSA));
98 FPM.addPass(InstCombinePass());
99 FPM.addPass(SimplifyCFGPass());
100 FPM.addPass(TailCallElimPass());
101 FPM.addPass(SimplifyCFGPass());
102 FPM.addPass(ReassociatePass());
105 LPM.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
106 FPM.addPass(createFunctionToLoopPassAdaptor<LoopPassManager>(
107 std::move(LPM),
false,
111 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
113 FPM = FunctionPassManager();
115 FPM.addPass(PromotePass());
116 FPM.addPass(SimplifyCFGPass());
117 FPM.addPass(InstCombinePass());
119 FPM.addPass(InstCombinePass());
122 LPM.addPass(IndVarSimplifyPass());
123 FPM.addPass(createFunctionToLoopPassAdaptor<LoopPassManager>(
124 std::move(LPM),
false,
132class PollyCanonicalize final :
public ModulePass {
133 PollyCanonicalize(
const PollyCanonicalize &) =
delete;
134 const PollyCanonicalize &operator=(
const PollyCanonicalize &) =
delete;
139 explicit PollyCanonicalize() : ModulePass(ID) {}
140 ~PollyCanonicalize();
144 void getAnalysisUsage(AnalysisUsage &AU)
const override;
145 void releaseMemory()
override;
146 bool runOnModule(Module &
M)
override;
147 void print(raw_ostream &OS,
const Module *)
const override;
152PollyCanonicalize::~PollyCanonicalize() {}
154void PollyCanonicalize::getAnalysisUsage(AnalysisUsage &AU)
const {}
156void PollyCanonicalize::releaseMemory() {}
158bool PollyCanonicalize::runOnModule(Module &
M) {
159 legacy::PassManager PM;
166void PollyCanonicalize::print(raw_ostream &OS,
const Module *)
const {}
168char PollyCanonicalize::ID = 0;
173 "Polly - Run canonicalization passes",
false,
false)
INITIALIZE_PASS_BEGIN(PollyCanonicalize, "polly-canonicalize", "Polly - Run canonicalization passes", false, false) INITIALIZE_PASS_END(PollyCanonicalize
static cl::opt< bool > PollyInliner("polly-run-inliner", cl::desc("Run an early inliner pass before Polly"), cl::Hidden, cl::cat(PollyCategory))
polly Polly Run canonicalization passes
static ModuleInlinerWrapperPass buildInlinePasses(llvm::OptimizationLevel Level)
Adapted from llvm::PassBuilder::buildInlinerPipeline.
INITIALIZE_PASS_END(DependenceInfo, "polly-dependences", "Polly - Calculate dependences", false, false) namespace
llvm::cl::OptionCategory PollyCategory
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
void registerCanonicalicationPasses(llvm::legacy::PassManagerBase &PM)
Schedule a set of canonicalization passes to prepare for Polly.
llvm::Pass * createPollyCanonicalizePass()
llvm::FunctionPassManager buildCanonicalicationPassesForNPM(llvm::ModulePassManager &MPM, llvm::OptimizationLevel Level)