diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp --- a/polly/lib/Support/RegisterPasses.cpp +++ b/polly/lib/Support/RegisterPasses.cpp @@ -433,53 +433,6 @@ ExportJScop; } -static void -registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { - if (PassPosition != POSITION_EARLY) - return; - - bool EnableForOpt = shouldEnablePollyForOptimization() && - Builder.OptLevel >= 1 && Builder.SizeLevel == 0; - if (!shouldEnablePollyForDiagnostic() && !EnableForOpt) - return; - - registerCanonicalicationPasses(PM); - registerPollyPasses(PM, EnableForOpt); -} - -static void -registerPollyLoopOptimizerEndPasses(const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { - if (PassPosition != POSITION_AFTER_LOOPOPT) - return; - - bool EnableForOpt = shouldEnablePollyForOptimization() && - Builder.OptLevel >= 1 && Builder.SizeLevel == 0; - if (!shouldEnablePollyForDiagnostic() && !EnableForOpt) - return; - - registerPollyPasses(PM, EnableForOpt); - if (EnableForOpt) - PM.add(createCodegenCleanupPass()); -} - -static void -registerPollyScalarOptimizerLatePasses(const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { - if (PassPosition != POSITION_BEFORE_VECTORIZER) - return; - - bool EnableForOpt = shouldEnablePollyForOptimization() && - Builder.OptLevel >= 1 && Builder.SizeLevel == 0; - if (!shouldEnablePollyForDiagnostic() && !EnableForOpt) - return; - - polly::registerPollyPasses(PM, EnableForOpt); - if (EnableForOpt) - PM.add(createCodegenCleanupPass()); -} - /// Add the pass sequence required for Polly to the New Pass Manager. /// /// @param PM The pass manager itself. @@ -646,55 +599,6 @@ false); } -/// Register Polly to be available as an optimizer -/// -/// -/// We can currently run Polly at three different points int the pass manager. -/// a) very early, b) after the canonicalizing loop transformations and c) right -/// before the vectorizer. -/// -/// The default is currently a), to register Polly such that it runs as early as -/// possible. This has several implications: -/// -/// 1) We need to schedule more canonicalization passes -/// -/// As nothing is run before Polly, it is necessary to run a set of preparing -/// transformations before Polly to canonicalize the LLVM-IR and to allow -/// Polly to detect and understand the code. -/// -/// 2) LICM and LoopIdiom pass have not yet been run -/// -/// Loop invariant code motion as well as the loop idiom recognition pass make -/// it more difficult for Polly to transform code. LICM may introduce -/// additional data dependences that are hard to eliminate and the loop idiom -/// recognition pass may introduce calls to memset that we currently do not -/// understand. By running Polly early enough (meaning before these passes) we -/// avoid difficulties that may be introduced by these passes. -/// -/// 3) We get the full -O3 optimization sequence after Polly -/// -/// The LLVM-IR that is generated by Polly has been optimized on a high level, -/// but it may be rather inefficient on the lower/scalar level. By scheduling -/// Polly before all other passes, we have the full sequence of -O3 -/// optimizations behind us, such that inefficiencies on the low level can -/// be optimized away. -/// -/// We are currently evaluating the benefit or running Polly at position b) or -/// c). b) is likely too early as it interacts with the inliner. c) is nice -/// as everything is fully inlined and canonicalized, but we need to be able -/// to handle LICMed code to make it useful. -static llvm::RegisterStandardPasses RegisterPollyOptimizerEarly( - llvm::PassManagerBuilder::EP_ModuleOptimizerEarly, - registerPollyEarlyAsPossiblePasses); - -static llvm::RegisterStandardPasses - RegisterPollyOptimizerLoopEnd(llvm::PassManagerBuilder::EP_LoopOptimizerEnd, - registerPollyLoopOptimizerEndPasses); - -static llvm::RegisterStandardPasses RegisterPollyOptimizerScalarLate( - llvm::PassManagerBuilder::EP_VectorizerStart, - registerPollyScalarOptimizerLatePasses); - static OwningScopAnalysisManagerFunctionProxy createScopAnalyses(FunctionAnalysisManager &FAM, PassInstrumentationCallbacks *PIC) { @@ -823,6 +727,43 @@ return true; } +/// Register Polly to be available as an optimizer +/// +/// +/// We can currently run Polly at three different points int the pass manager. +/// a) very early, b) after the canonicalizing loop transformations and c) right +/// before the vectorizer. +/// +/// The default is currently a), to register Polly such that it runs as early as +/// possible. This has several implications: +/// +/// 1) We need to schedule more canonicalization passes +/// +/// As nothing is run before Polly, it is necessary to run a set of preparing +/// transformations before Polly to canonicalize the LLVM-IR and to allow +/// Polly to detect and understand the code. +/// +/// 2) LICM and LoopIdiom pass have not yet been run +/// +/// Loop invariant code motion as well as the loop idiom recognition pass make +/// it more difficult for Polly to transform code. LICM may introduce +/// additional data dependences that are hard to eliminate and the loop idiom +/// recognition pass may introduce calls to memset that we currently do not +/// understand. By running Polly early enough (meaning before these passes) we +/// avoid difficulties that may be introduced by these passes. +/// +/// 3) We get the full -O3 optimization sequence after Polly +/// +/// The LLVM-IR that is generated by Polly has been optimized on a high level, +/// but it may be rather inefficient on the lower/scalar level. By scheduling +/// Polly before all other passes, we have the full sequence of -O3 +/// optimizations behind us, such that inefficiencies on the low level can +/// be optimized away. +/// +/// We are currently evaluating the benefit or running Polly at position b) or +/// c). b) is likely too early as it interacts with the inliner. c) is nice +/// as everything is fully inlined and canonicalized, but we need to be able +/// to handle LICMed code to make it useful. void registerPollyPasses(PassBuilder &PB) { PassInstrumentationCallbacks *PIC = PB.getPassInstrumentationCallbacks(); PB.registerAnalysisRegistrationCallback([PIC](FunctionAnalysisManager &FAM) {