[polly] r242390 - Add option to choose where in the pass pipeline polly is run
Tobias Grosser
tobias at grosser.es
Thu Jul 16 01:28:09 PDT 2015
Author: grosser
Date: Thu Jul 16 03:28:09 2015
New Revision: 242390
URL: http://llvm.org/viewvc/llvm-project?rev=242390&view=rev
Log:
Add option to choose where in the pass pipeline polly is run
These options are useful to play with the location of Polly within LLVM's
pass manager.
Modified:
polly/trunk/lib/Support/RegisterPasses.cpp
Modified: polly/trunk/lib/Support/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/RegisterPasses.cpp?rev=242390&r1=242389&r2=242390&view=diff
==============================================================================
--- polly/trunk/lib/Support/RegisterPasses.cpp (original)
+++ polly/trunk/lib/Support/RegisterPasses.cpp Thu Jul 16 03:28:09 2015
@@ -49,8 +49,26 @@ static cl::opt<bool> PollyDetectOnly(
cl::desc("Only run scop detection, but no other optimizations"),
cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
+enum PassPositionChoice {
+ POSITION_EARLY,
+ POSITION_AFTER_LOOPOPT,
+ POSITION_BEFORE_VECTORIZER
+};
+
enum OptimizerChoice { OPTIMIZER_NONE, OPTIMIZER_ISL };
+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_AFTER_LOOPOPT, "after-loopopt",
+ "After the loop optimizer (but within the inline zycle)"),
+ clEnumValN(POSITION_BEFORE_VECTORIZER, "before-vectorizer",
+ "Right before the vectorizer"),
+ clEnumValEnd),
+ cl::Hidden, cl::init(POSITION_EARLY), cl::ZeroOrMore,
+ cl::cat(PollyCategory));
+
static cl::opt<OptimizerChoice> Optimizer(
"polly-optimizer", cl::desc("Select the scheduling optimizer"),
cl::values(clEnumValN(OPTIMIZER_NONE, "none", "No optimizer"),
@@ -167,8 +185,6 @@ void initializePollyPasses(PassRegistry
///
/// Polly supports the isl internal code generator.
void registerPollyPasses(llvm::legacy::PassManagerBase &PM) {
- registerCanonicalicationPasses(PM);
-
PM.add(polly::createScopDetectionPass());
if (PollyDetectOnly)
@@ -232,13 +248,48 @@ registerPollyEarlyAsPossiblePasses(const
if (!polly::shouldEnablePolly())
return;
+ if (PassPosition != POSITION_EARLY)
+ return;
+
+ registerCanonicalicationPasses(PM);
+ polly::registerPollyPasses(PM);
+}
+
+static void
+registerPollyLoopOptimizerEndPasses(const llvm::PassManagerBuilder &Builder,
+ llvm::legacy::PassManagerBase &PM) {
+ if (!polly::shouldEnablePolly())
+ return;
+
+ if (PassPosition != POSITION_AFTER_LOOPOPT)
+ return;
+
polly::registerPollyPasses(PM);
+ // TODO: Add some cleanup passes
+}
+
+static void
+registerPollyScalarOptimizerLatePasses(const llvm::PassManagerBuilder &Builder,
+ llvm::legacy::PassManagerBase &PM) {
+ if (!polly::shouldEnablePolly())
+ return;
+
+ if (PassPosition != POSITION_BEFORE_VECTORIZER)
+ return;
+
+ polly::registerPollyPasses(PM);
+ // TODO: Add some cleanup passes
}
/// @brief Register Polly to be available as an optimizer
///
-/// We currently register Polly such that it runs as early as possible. This has
-/// several implications:
+///
+/// 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
///
@@ -262,7 +313,20 @@ registerPollyEarlyAsPossiblePasses(const
/// 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 to 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_EarlyAsPossible,
+ registerPollyEarlyAsPossiblePasses);
+
static llvm::RegisterStandardPasses
- RegisterPollyOptimizer(llvm::PassManagerBuilder::EP_EarlyAsPossible,
- registerPollyEarlyAsPossiblePasses);
+ RegisterPollyOptimizerLoopEnd(llvm::PassManagerBuilder::EP_LoopOptimizerEnd,
+ registerPollyLoopOptimizerEndPasses);
+
+static llvm::RegisterStandardPasses RegisterPollyOptimizerScalarLate(
+ llvm::PassManagerBuilder::EP_VectorizerStart,
+ registerPollyScalarOptimizerLatePasses);
}
More information about the llvm-commits
mailing list