Polly 20.0.0git
RegisterPasses.cpp
Go to the documentation of this file.
1//===------ RegisterPasses.cpp - Add the Polly Passes to default passes --===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file composes the individual LLVM-IR passes provided by Polly to a
10// functional polyhedral optimizer. The polyhedral optimizer is automatically
11// made available to LLVM based compilers by loading the Polly shared library
12// into such a compiler.
13//
14// The Polly optimizer is made available by executing a static constructor that
15// registers the individual Polly passes in the LLVM pass manager builder. The
16// passes are registered such that the default behaviour of the compiler is not
17// changed, but that the flag '-polly' provided at optimization level '-O3'
18// enables additional polyhedral optimizations.
19//===----------------------------------------------------------------------===//
20
26#include "polly/DeLICM.h"
29#include "polly/ForwardOpTree.h"
30#include "polly/JSONExporter.h"
31#include "polly/LinkAllPasses.h"
36#include "polly/ScopDetection.h"
38#include "polly/ScopInfo.h"
39#include "polly/Simplify.h"
42#include "llvm/Analysis/CFGPrinter.h"
43#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_STRING
44#include "llvm/IR/LegacyPassManager.h"
45#include "llvm/IR/PassManager.h"
46#include "llvm/IR/Verifier.h"
47#include "llvm/Passes/PassBuilder.h"
48#include "llvm/Passes/PassPlugin.h"
49#include "llvm/Support/CommandLine.h"
50#include "llvm/Support/TargetSelect.h"
51#include "llvm/Transforms/IPO.h"
52
53namespace cl = llvm::cl;
54
55using llvm::FunctionPassManager;
56using llvm::OptimizationLevel;
57using llvm::PassBuilder;
58using llvm::PassInstrumentationCallbacks;
59
60cl::OptionCategory PollyCategory("Polly Options",
61 "Configure the polly loop optimizer");
62
63namespace polly {
64static cl::opt<bool>
65 PollyEnabled("polly",
66 cl::desc("Enable the polly optimizer (with -O1, -O2 or -O3)"),
67 cl::cat(PollyCategory));
68
69static cl::opt<bool> PollyDetectOnly(
70 "polly-only-scop-detection",
71 cl::desc("Only run scop detection, but no other optimizations"),
72 cl::cat(PollyCategory));
73
75
77
78static cl::opt<PassPositionChoice> PassPosition(
79 "polly-position", cl::desc("Where to run polly in the pass pipeline"),
80 cl::values(clEnumValN(POSITION_EARLY, "early", "Before everything"),
81 clEnumValN(POSITION_BEFORE_VECTORIZER, "before-vectorizer",
82 "Right before the vectorizer")),
83 cl::Hidden, cl::init(POSITION_BEFORE_VECTORIZER), cl::cat(PollyCategory));
84
85static cl::opt<OptimizerChoice>
86 Optimizer("polly-optimizer", cl::desc("Select the scheduling optimizer"),
87 cl::values(clEnumValN(OPTIMIZER_NONE, "none", "No optimizer"),
88 clEnumValN(OPTIMIZER_ISL, "isl",
89 "The isl scheduling optimizer")),
90 cl::Hidden, cl::init(OPTIMIZER_ISL), cl::cat(PollyCategory));
91
93static cl::opt<CodeGenChoice> CodeGeneration(
94 "polly-code-generation", cl::desc("How much code-generation to perform"),
95 cl::values(clEnumValN(CODEGEN_FULL, "full", "AST and IR generation"),
96 clEnumValN(CODEGEN_AST, "ast", "Only AST generation"),
97 clEnumValN(CODEGEN_NONE, "none", "No code generation")),
98 cl::Hidden, cl::init(CODEGEN_FULL), cl::cat(PollyCategory));
99
101
102static cl::opt<VectorizerChoice, true> Vectorizer(
103 "polly-vectorizer", cl::desc("Select the vectorization strategy"),
104 cl::values(
105 clEnumValN(VECTORIZER_NONE, "none", "No Vectorization"),
106 clEnumValN(
107 VECTORIZER_STRIPMINE, "stripmine",
108 "Strip-mine outer loops for the loop-vectorizer to trigger")),
109 cl::location(PollyVectorizerChoice), cl::init(VECTORIZER_NONE),
110 cl::cat(PollyCategory));
111
112static cl::opt<bool> ImportJScop(
113 "polly-import",
114 cl::desc("Import the polyhedral description of the detected Scops"),
115 cl::Hidden, cl::cat(PollyCategory));
116
117static cl::opt<bool> FullyIndexedStaticExpansion(
118 "polly-enable-mse",
119 cl::desc("Fully expand the memory accesses of the detected Scops"),
120 cl::Hidden, cl::cat(PollyCategory));
121
122static cl::opt<bool> ExportJScop(
123 "polly-export",
124 cl::desc("Export the polyhedral description of the detected Scops"),
125 cl::Hidden, cl::cat(PollyCategory));
126
127static cl::opt<bool> DeadCodeElim("polly-run-dce",
128 cl::desc("Run the dead code elimination"),
129 cl::Hidden, cl::cat(PollyCategory));
130
131static cl::opt<bool> PollyViewer(
132 "polly-show",
133 cl::desc("Highlight the code regions that will be optimized in a "
134 "(CFG BBs and LLVM-IR instructions)"),
135 cl::cat(PollyCategory));
136
137static cl::opt<bool> PollyOnlyViewer(
138 "polly-show-only",
139 cl::desc("Highlight the code regions that will be optimized in "
140 "a (CFG only BBs)"),
141 cl::init(false), cl::cat(PollyCategory));
142
143static cl::opt<bool>
144 PollyPrinter("polly-dot", cl::desc("Enable the Polly DOT printer in -O3"),
145 cl::Hidden, cl::value_desc("Run the Polly DOT printer at -O3"),
146 cl::init(false), cl::cat(PollyCategory));
147
148static cl::opt<bool> PollyOnlyPrinter(
149 "polly-dot-only",
150 cl::desc("Enable the Polly DOT printer in -O3 (no BB content)"), cl::Hidden,
151 cl::value_desc("Run the Polly DOT printer at -O3 (no BB content"),
152 cl::init(false), cl::cat(PollyCategory));
153
154static cl::opt<bool>
155 CFGPrinter("polly-view-cfg",
156 cl::desc("Show the Polly CFG right after code generation"),
157 cl::Hidden, cl::init(false), cl::cat(PollyCategory));
158
159static cl::opt<bool>
160 EnableForwardOpTree("polly-enable-optree",
161 cl::desc("Enable operand tree forwarding"), cl::Hidden,
162 cl::init(true), cl::cat(PollyCategory));
163
164static cl::opt<bool>
165 DumpBefore("polly-dump-before",
166 cl::desc("Dump module before Polly transformations into a file "
167 "suffixed with \"-before\""),
168 cl::init(false), cl::cat(PollyCategory));
169
170static cl::list<std::string> DumpBeforeFile(
171 "polly-dump-before-file",
172 cl::desc("Dump module before Polly transformations to the given file"),
173 cl::cat(PollyCategory));
174
175static cl::opt<bool>
176 DumpAfter("polly-dump-after",
177 cl::desc("Dump module after Polly transformations into a file "
178 "suffixed with \"-after\""),
179 cl::init(false), cl::cat(PollyCategory));
180
181static cl::list<std::string> DumpAfterFile(
182 "polly-dump-after-file",
183 cl::desc("Dump module after Polly transformations to the given file"),
184 cl::cat(PollyCategory));
185
186static cl::opt<bool>
187 EnableDeLICM("polly-enable-delicm",
188 cl::desc("Eliminate scalar loop carried dependences"),
189 cl::Hidden, cl::init(true), cl::cat(PollyCategory));
190
191static cl::opt<bool>
192 EnableSimplify("polly-enable-simplify",
193 cl::desc("Simplify SCoP after optimizations"),
194 cl::init(true), cl::cat(PollyCategory));
195
196static cl::opt<bool> EnablePruneUnprofitable(
197 "polly-enable-prune-unprofitable",
198 cl::desc("Bail out on unprofitable SCoPs before rescheduling"), cl::Hidden,
199 cl::init(true), cl::cat(PollyCategory));
200
201namespace {
202
203/// Initialize Polly passes when library is loaded.
204///
205/// We use the constructor of a statically declared object to initialize the
206/// different Polly passes right after the Polly library is loaded. This ensures
207/// that the Polly passes are available e.g. in the 'opt' tool.
208struct StaticInitializer {
209 StaticInitializer() {
210 llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry();
212 }
213};
214static StaticInitializer InitializeEverything;
215} // end of anonymous namespace.
216
217void initializePollyPasses(llvm::PassRegistry &Registry) {
219
254}
255
257
259 // FIXME: PollyTrackFailures is user-controlled, should not be set
260 // programmatically.
262 PollyTrackFailures = true;
263
266}
267
268/// Register Polly passes such that they form a polyhedral optimizer.
269///
270/// The individual Polly passes are registered in the pass manager such that
271/// they form a full polyhedral optimizer. The flow of the optimizer starts with
272/// a set of preparing transformations that canonicalize the LLVM-IR such that
273/// the LLVM-IR is easier for us to understand and to optimizes. On the
274/// canonicalized LLVM-IR we first run the ScopDetection pass, which detects
275/// static control flow regions. Those regions are then translated by the
276/// ScopInfo pass into a polyhedral representation. As a next step, a scheduling
277/// optimizer is run on the polyhedral representation and finally the optimized
278/// polyhedral representation is code generated back to LLVM-IR.
279///
280/// Besides this core functionality, we optionally schedule passes that provide
281/// a graphical view of the scops (Polly[Only]Viewer, Polly[Only]Printer), that
282/// allow the export/import of the polyhedral representation
283/// (JSCON[Exporter|Importer]) or that show the cfg after code generation.
284///
285/// For certain parts of the Polly optimizer, several alternatives are provided:
286///
287/// As scheduling optimizer we support the isl scheduling optimizer
288/// (http://freecode.com/projects/isl).
289/// It is also possible to run Polly with no optimizer. This mode is mainly
290/// provided to analyze the run and compile time changes caused by the
291/// scheduling optimizer.
292///
293/// Polly supports the isl internal code generator.
294
295/// Add the pass sequence required for Polly to the New Pass Manager.
296///
297/// @param PM The pass manager itself.
298/// @param Level The optimization level. Used for the cleanup of Polly's
299/// output.
300/// @param EnableForOpt Whether to add Polly IR transformations. If False, only
301/// the analysis passes are added, skipping Polly itself.
302/// The IR may still be modified.
303static void buildCommonPollyPipeline(FunctionPassManager &PM,
304 OptimizationLevel Level,
305 bool EnableForOpt) {
306 PassBuilder PB;
307 ScopPassManager SPM;
308
309 PM.addPass(CodePreparationPass());
310
311 // TODO add utility passes for the various command line options, once they're
312 // ported
313
314 if (PollyDetectOnly) {
315 // Don't add more passes other than the ScopPassManager's detection passes.
316 PM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
317 return;
318 }
319
320 if (PollyViewer)
321 PM.addPass(ScopViewer());
322 if (PollyOnlyViewer)
323 PM.addPass(ScopOnlyViewer());
324 if (PollyPrinter)
325 PM.addPass(ScopPrinter());
327 PM.addPass(ScopOnlyPrinter());
328 if (EnableSimplify)
329 SPM.addPass(SimplifyPass(0));
331 SPM.addPass(ForwardOpTreePass());
332 if (EnableDeLICM)
333 SPM.addPass(DeLICMPass());
334 if (EnableSimplify)
335 SPM.addPass(SimplifyPass(1));
336
337 if (ImportJScop)
338 SPM.addPass(JSONImportPass());
339
340 if (DeadCodeElim)
341 SPM.addPass(DeadCodeElimPass());
342
344 SPM.addPass(MaximalStaticExpansionPass());
345
347 SPM.addPass(PruneUnprofitablePass());
348
349 switch (Optimizer) {
350 case OPTIMIZER_NONE:
351 break; /* Do nothing */
352 case OPTIMIZER_ISL:
353 SPM.addPass(IslScheduleOptimizerPass());
354 break;
355 }
356
357 if (ExportJScop)
358 SPM.addPass(JSONExportPass());
359
360 if (!EnableForOpt)
361 return;
362
363 switch (CodeGeneration) {
364 case CODEGEN_AST:
365 SPM.addPass(
366 llvm::RequireAnalysisPass<IslAstAnalysis, Scop, ScopAnalysisManager,
368 SPMUpdater &>());
369 break;
370 case CODEGEN_FULL:
371 SPM.addPass(CodeGenerationPass());
372 break;
373 case CODEGEN_NONE:
374 break;
375 }
376
377 PM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
378 PM.addPass(PB.buildFunctionSimplificationPipeline(
379 Level, llvm::ThinOrFullLTOPhase::None)); // Cleanup
380
381 if (CFGPrinter)
382 PM.addPass(llvm::CFGPrinterPass());
383}
384
385static void buildEarlyPollyPipeline(llvm::ModulePassManager &MPM,
386 llvm::OptimizationLevel Level) {
387 bool EnableForOpt =
388 shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
389 if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
390 return;
391
392 FunctionPassManager FPM = buildCanonicalicationPassesForNPM(MPM, Level);
393
394 if (DumpBefore || !DumpBeforeFile.empty()) {
395 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
396
397 if (DumpBefore)
398 MPM.addPass(DumpModulePass("-before", true));
399 for (auto &Filename : DumpBeforeFile)
400 MPM.addPass(DumpModulePass(Filename, false));
401
402 FPM = FunctionPassManager();
403 }
404
405 buildCommonPollyPipeline(FPM, Level, EnableForOpt);
406 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
407
408 if (DumpAfter)
409 MPM.addPass(DumpModulePass("-after", true));
410 for (auto &Filename : DumpAfterFile)
411 MPM.addPass(DumpModulePass(Filename, false));
412}
413
414static void buildLatePollyPipeline(FunctionPassManager &PM,
415 llvm::OptimizationLevel Level) {
416 bool EnableForOpt =
417 shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
418 if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
419 return;
420
421 if (DumpBefore)
422 PM.addPass(DumpFunctionPass("-before"));
423 if (!DumpBeforeFile.empty())
424 llvm::report_fatal_error(
425 "Option -polly-dump-before-file at -polly-position=late "
426 "not supported with NPM",
427 false);
428
429 buildCommonPollyPipeline(PM, Level, EnableForOpt);
430
431 if (DumpAfter)
432 PM.addPass(DumpFunctionPass("-after"));
433 if (!DumpAfterFile.empty())
434 llvm::report_fatal_error(
435 "Option -polly-dump-after-file at -polly-position=late "
436 "not supported with NPM",
437 false);
438}
439
441createScopAnalyses(FunctionAnalysisManager &FAM,
442 PassInstrumentationCallbacks *PIC) {
444#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
445 Proxy.getManager().registerPass([PIC] { \
446 (void)PIC; \
447 return CREATE_PASS; \
448 });
449#include "PollyPasses.def"
450
451 Proxy.getManager().registerPass(
452 [&FAM] { return FunctionAnalysisManagerScopProxy(FAM); });
453 return Proxy;
454}
455
456static void registerFunctionAnalyses(FunctionAnalysisManager &FAM,
457 PassInstrumentationCallbacks *PIC) {
458
459#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
460 FAM.registerPass([] { return CREATE_PASS; });
461
462#include "PollyPasses.def"
463
464 FAM.registerPass([&FAM, PIC] { return createScopAnalyses(FAM, PIC); });
465}
466
467static bool
468parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
469 ArrayRef<PassBuilder::PipelineElement> Pipeline) {
470 if (llvm::parseAnalysisUtilityPasses<OwningScopAnalysisManagerFunctionProxy>(
471 "polly-scop-analyses", Name, FPM))
472 return true;
473
474#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
475 if (llvm::parseAnalysisUtilityPasses< \
476 std::remove_reference<decltype(CREATE_PASS)>::type>(NAME, Name, \
477 FPM)) \
478 return true;
479
480#define FUNCTION_PASS(NAME, CREATE_PASS) \
481 if (Name == NAME) { \
482 FPM.addPass(CREATE_PASS); \
483 return true; \
484 }
485
486#include "PollyPasses.def"
487 return false;
488}
489
490static bool parseScopPass(StringRef Name, ScopPassManager &SPM,
491 PassInstrumentationCallbacks *PIC) {
492#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
493 if (llvm::parseAnalysisUtilityPasses< \
494 std::remove_reference<decltype(CREATE_PASS)>::type>(NAME, Name, \
495 SPM)) \
496 return true;
497
498#define SCOP_PASS(NAME, CREATE_PASS) \
499 if (Name == NAME) { \
500 SPM.addPass(CREATE_PASS); \
501 return true; \
502 }
503
504#include "PollyPasses.def"
505
506 return false;
507}
508
509static bool parseScopPipeline(StringRef Name, FunctionPassManager &FPM,
510 PassInstrumentationCallbacks *PIC,
511 ArrayRef<PassBuilder::PipelineElement> Pipeline) {
512 if (Name != "scop")
513 return false;
514 if (!Pipeline.empty()) {
515 ScopPassManager SPM;
516 for (const auto &E : Pipeline)
517 if (!parseScopPass(E.Name, SPM, PIC))
518 return false;
519 FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
520 }
521 return true;
522}
523
524static bool isScopPassName(StringRef Name) {
525#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
526 if (Name == "require<" NAME ">") \
527 return true; \
528 if (Name == "invalidate<" NAME ">") \
529 return true;
530
531#define SCOP_PASS(NAME, CREATE_PASS) \
532 if (Name == NAME) \
533 return true;
534
535#include "PollyPasses.def"
536
537 return false;
538}
539
540static bool
541parseTopLevelPipeline(llvm::ModulePassManager &MPM,
542 PassInstrumentationCallbacks *PIC,
543 ArrayRef<PassBuilder::PipelineElement> Pipeline) {
544 std::vector<PassBuilder::PipelineElement> FullPipeline;
545 StringRef FirstName = Pipeline.front().Name;
546
547 if (!isScopPassName(FirstName))
548 return false;
549
550 FunctionPassManager FPM;
551 ScopPassManager SPM;
552
553 for (auto &Element : Pipeline) {
554 auto &Name = Element.Name;
555 auto &InnerPipeline = Element.InnerPipeline;
556 if (!InnerPipeline.empty()) // Scop passes don't have inner pipelines
557 return false;
558 if (!parseScopPass(Name, SPM, PIC))
559 return false;
560 }
561
562 FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
563 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
564
565 return true;
566}
567
568/// Register Polly to be available as an optimizer
569///
570///
571/// We can currently run Polly at two different points int the pass manager.
572/// a) very early, b) right before the vectorizer.
573///
574/// The default is currently a), to register Polly such that it runs as early as
575/// possible. This has several implications:
576///
577/// 1) We need to schedule more canonicalization passes
578///
579/// As nothing is run before Polly, it is necessary to run a set of preparing
580/// transformations before Polly to canonicalize the LLVM-IR and to allow
581/// Polly to detect and understand the code.
582///
583/// 2) We get the full -O3 optimization sequence after Polly
584///
585/// The LLVM-IR that is generated by Polly has been optimized on a high level,
586/// but it may be rather inefficient on the lower/scalar level. By scheduling
587/// Polly before all other passes, we have the full sequence of -O3
588/// optimizations behind us, such that inefficiencies on the low level can
589/// be optimized away.
590///
591/// We are currently evaluating the benefit or running Polly at b). b) is nice
592/// as everything is fully inlined and canonicalized, but we need to be able to
593/// handle LICMed code to make it useful.
594void registerPollyPasses(PassBuilder &PB) {
595 PassInstrumentationCallbacks *PIC = PB.getPassInstrumentationCallbacks();
596 PB.registerAnalysisRegistrationCallback([PIC](FunctionAnalysisManager &FAM) {
597 registerFunctionAnalyses(FAM, PIC);
598 });
599 PB.registerPipelineParsingCallback(parseFunctionPipeline);
600 PB.registerPipelineParsingCallback(
601 [PIC](StringRef Name, FunctionPassManager &FPM,
602 ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
603 return parseScopPipeline(Name, FPM, PIC, Pipeline);
604 });
605 PB.registerParseTopLevelPipelineCallback(
606 [PIC](llvm::ModulePassManager &MPM,
607 ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
608 return parseTopLevelPipeline(MPM, PIC, Pipeline);
609 });
610
611 switch (PassPosition) {
612 case POSITION_EARLY:
613 PB.registerPipelineStartEPCallback(buildEarlyPollyPipeline);
614 break;
616 PB.registerVectorizerStartEPCallback(buildLatePollyPipeline);
617 break;
618 }
619}
620} // namespace polly
621
622llvm::PassPluginLibraryInfo getPollyPluginInfo() {
623 return {LLVM_PLUGIN_API_VERSION, "Polly", LLVM_VERSION_STRING,
625}
llvm::cl::OptionCategory PollyCategory
llvm::PassPluginLibraryInfo getPollyPluginInfo()
AnalysisManagerT & getManager()
Definition: ScopPass.h:139
Static Control Part.
Definition: ScopInfo.h:1630
void initializePolyhedralInfoPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeScopDetectionWrapperPassPass(llvm::PassRegistry &)
void initializeScopInfoPrinterLegacyRegionPassPass(llvm::PassRegistry &)
void initializeDependenceInfoWrapperPassPass(llvm::PassRegistry &)
void initializeScopInfoRegionPassPass(PassRegistry &)
void initializeScopInfoPrinterLegacyFunctionPassPass(PassRegistry &)
void initializeDependenceInfoPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeCodeGenerationPass(llvm::PassRegistry &)
void initializeIslAstInfoPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeMaximalStaticExpanderWrapperPassPass(llvm::PassRegistry &)
void initializeScopInlinerPass(llvm::PassRegistry &)
void initializeSimplifyWrapperPassPass(llvm::PassRegistry &)
void initializeScopDetectionPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeJSONImporterPass(llvm::PassRegistry &)
void initializePollyCanonicalizePass(llvm::PassRegistry &)
void initializeIslAstInfoWrapperPassPass(llvm::PassRegistry &)
void initializePruneUnprofitableWrapperPassPass(llvm::PassRegistry &)
void initializeFlattenSchedulePrinterLegacyPassPass(llvm::PassRegistry &)
void initializeForwardOpTreeWrapperPassPass(PassRegistry &)
void initializeJSONExporterPass(llvm::PassRegistry &)
void initializePolyhedralInfoPass(llvm::PassRegistry &)
void initializeDependenceInfoPass(llvm::PassRegistry &)
void initializeIslScheduleOptimizerWrapperPassPass(llvm::PassRegistry &)
void initializeDumpModuleWrapperPassPass(llvm::PassRegistry &)
void initializeDependenceInfoPrinterLegacyFunctionPassPass(llvm::PassRegistry &)
void initializeSimplifyPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeScopInfoWrapperPassPass(PassRegistry &)
void initializeCodePreparationPass(llvm::PassRegistry &)
void initializeFlattenSchedulePass(llvm::PassRegistry &)
void initializeIslScheduleOptimizerPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeDeLICMPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeDeLICMWrapperPassPass(llvm::PassRegistry &)
void initializeJSONImporterPrinterLegacyPassPass(llvm::PassRegistry &)
void initializeForwardOpTreePrinterLegacyPassPass(PassRegistry &)
void initializeDeadCodeElimWrapperPassPass(llvm::PassRegistry &)
static cl::opt< bool > ExportJScop("polly-export", cl::desc("Export the polyhedral description of the detected Scops"), cl::Hidden, cl::cat(PollyCategory))
@ OPTIMIZER_NONE
static cl::opt< bool > FullyIndexedStaticExpansion("polly-enable-mse", cl::desc("Fully expand the memory accesses of the detected Scops"), cl::Hidden, cl::cat(PollyCategory))
@ POSITION_EARLY
@ POSITION_BEFORE_VECTORIZER
static bool parseTopLevelPipeline(llvm::ModulePassManager &MPM, PassInstrumentationCallbacks *PIC, ArrayRef< PassBuilder::PipelineElement > Pipeline)
static cl::list< std::string > DumpBeforeFile("polly-dump-before-file", cl::desc("Dump module before Polly transformations to the given file"), cl::cat(PollyCategory))
static bool shouldEnablePollyForDiagnostic()
FunctionToScopPassAdaptor< ScopPassT > createFunctionToScopPassAdaptor(ScopPassT Pass)
Definition: ScopPass.h:287
static cl::opt< VectorizerChoice, true > Vectorizer("polly-vectorizer", cl::desc("Select the vectorization strategy"), cl::values(clEnumValN(VECTORIZER_NONE, "none", "No Vectorization"), clEnumValN(VECTORIZER_STRIPMINE, "stripmine", "Strip-mine outer loops for the loop-vectorizer to trigger")), cl::location(PollyVectorizerChoice), cl::init(VECTORIZER_NONE), cl::cat(PollyCategory))
static cl::opt< bool > PollyOnlyViewer("polly-show-only", cl::desc("Highlight the code regions that will be optimized in " "a (CFG only BBs)"), cl::init(false), cl::cat(PollyCategory))
static void buildLatePollyPipeline(FunctionPassManager &PM, llvm::OptimizationLevel Level)
static cl::opt< bool > EnableSimplify("polly-enable-simplify", cl::desc("Simplify SCoP after optimizations"), cl::init(true), cl::cat(PollyCategory))
PassManager< Scop, ScopAnalysisManager, ScopStandardAnalysisResults &, SPMUpdater & > ScopPassManager
Definition: ScopPass.h:156
bool PollyTrackFailures
static cl::opt< OptimizerChoice > Optimizer("polly-optimizer", cl::desc("Select the scheduling optimizer"), cl::values(clEnumValN(OPTIMIZER_NONE, "none", "No optimizer"), clEnumValN(OPTIMIZER_ISL, "isl", "The isl scheduling optimizer")), cl::Hidden, cl::init(OPTIMIZER_ISL), cl::cat(PollyCategory))
void registerPollyPasses(llvm::PassBuilder &PB)
static cl::opt< bool > PollyViewer("polly-show", cl::desc("Highlight the code regions that will be optimized in a " "(CFG BBs and LLVM-IR instructions)"), cl::cat(PollyCategory))
static cl::opt< bool > PollyPrinter("polly-dot", cl::desc("Enable the Polly DOT printer in -O3"), cl::Hidden, cl::value_desc("Run the Polly DOT printer at -O3"), cl::init(false), cl::cat(PollyCategory))
static cl::opt< bool > PollyEnabled("polly", cl::desc("Enable the polly optimizer (with -O1, -O2 or -O3)"), cl::cat(PollyCategory))
VectorizerChoice
@ VECTORIZER_STRIPMINE
@ VECTORIZER_NONE
VectorizerChoice PollyVectorizerChoice
static cl::opt< bool > DumpBefore("polly-dump-before", cl::desc("Dump module before Polly transformations into a file " "suffixed with \"-before\""), cl::init(false), cl::cat(PollyCategory))
void initializePollyPasses(llvm::PassRegistry &Registry)
static cl::opt< bool > EnableForwardOpTree("polly-enable-optree", cl::desc("Enable operand tree forwarding"), cl::Hidden, cl::init(true), cl::cat(PollyCategory))
static cl::opt< bool > DumpAfter("polly-dump-after", cl::desc("Dump module after Polly transformations into a file " "suffixed with \"-after\""), cl::init(false), cl::cat(PollyCategory))
static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM, ArrayRef< PassBuilder::PipelineElement > Pipeline)
static cl::opt< bool > PollyDetectOnly("polly-only-scop-detection", cl::desc("Only run scop detection, but no other optimizations"), cl::cat(PollyCategory))
static cl::opt< bool > CFGPrinter("polly-view-cfg", cl::desc("Show the Polly CFG right after code generation"), cl::Hidden, cl::init(false), cl::cat(PollyCategory))
static bool isScopPassName(StringRef Name)
static void registerFunctionAnalyses(FunctionAnalysisManager &FAM, PassInstrumentationCallbacks *PIC)
static cl::opt< bool > DeadCodeElim("polly-run-dce", cl::desc("Run the dead code elimination"), cl::Hidden, cl::cat(PollyCategory))
static void buildCommonPollyPipeline(FunctionPassManager &PM, OptimizationLevel Level, bool EnableForOpt)
Register Polly passes such that they form a polyhedral optimizer.
static cl::opt< bool > EnablePruneUnprofitable("polly-enable-prune-unprofitable", cl::desc("Bail out on unprofitable SCoPs before rescheduling"), cl::Hidden, cl::init(true), cl::cat(PollyCategory))
static cl::opt< bool > EnableDeLICM("polly-enable-delicm", cl::desc("Eliminate scalar loop carried dependences"), cl::Hidden, cl::init(true), cl::cat(PollyCategory))
static OwningScopAnalysisManagerFunctionProxy createScopAnalyses(FunctionAnalysisManager &FAM, PassInstrumentationCallbacks *PIC)
static bool parseScopPipeline(StringRef Name, FunctionPassManager &FPM, PassInstrumentationCallbacks *PIC, ArrayRef< PassBuilder::PipelineElement > Pipeline)
static cl::opt< bool > ImportJScop("polly-import", cl::desc("Import the polyhedral description of the detected Scops"), cl::Hidden, cl::cat(PollyCategory))
static cl::opt< bool > PollyOnlyPrinter("polly-dot-only", cl::desc("Enable the Polly DOT printer in -O3 (no BB content)"), cl::Hidden, cl::value_desc("Run the Polly DOT printer at -O3 (no BB content"), cl::init(false), cl::cat(PollyCategory))
llvm::FunctionPassManager buildCanonicalicationPassesForNPM(llvm::ModulePassManager &MPM, llvm::OptimizationLevel Level)
AnalysisManager< Scop, ScopStandardAnalysisResults & > ScopAnalysisManager
Definition: ScopPass.h:46
static cl::opt< PassPositionChoice > PassPosition("polly-position", cl::desc("Where to run polly in the pass pipeline"), cl::values(clEnumValN(POSITION_EARLY, "early", "Before everything"), clEnumValN(POSITION_BEFORE_VECTORIZER, "before-vectorizer", "Right before the vectorizer")), cl::Hidden, cl::init(POSITION_BEFORE_VECTORIZER), cl::cat(PollyCategory))
static cl::list< std::string > DumpAfterFile("polly-dump-after-file", cl::desc("Dump module after Polly transformations to the given file"), cl::cat(PollyCategory))
static bool shouldEnablePollyForOptimization()
OwningInnerAnalysisManagerProxy< ScopAnalysisManager, Function > OwningScopAnalysisManagerFunctionProxy
Definition: ScopPass.h:153
static void buildEarlyPollyPipeline(llvm::ModulePassManager &MPM, llvm::OptimizationLevel Level)
OuterAnalysisManagerProxy< FunctionAnalysisManager, Scop, ScopStandardAnalysisResults & > FunctionAnalysisManagerScopProxy
Definition: ScopPass.h:51
static cl::opt< CodeGenChoice > CodeGeneration("polly-code-generation", cl::desc("How much code-generation to perform"), cl::values(clEnumValN(CODEGEN_FULL, "full", "AST and IR generation"), clEnumValN(CODEGEN_AST, "ast", "Only AST generation"), clEnumValN(CODEGEN_NONE, "none", "No code generation")), cl::Hidden, cl::init(CODEGEN_FULL), cl::cat(PollyCategory))
static bool parseScopPass(StringRef Name, ScopPassManager &SPM, PassInstrumentationCallbacks *PIC)
A pass that isolates a function into a new Module and writes it into a file.
A pass that prints the module into a file.
This pass exports a scop to a jscop file.
Definition: JSONExporter.h:22
This pass imports a scop from a jscop file.
Definition: JSONExporter.h:29