mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
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. llvm-svn: 242390
This commit is contained in:
parent
39a7bd182e
commit
d783a98303
@ -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 &Registry) {
|
||||
///
|
||||
/// 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 llvm::PassManagerBuilder &Builder,
|
||||
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 llvm::PassManagerBuilder &Builder,
|
||||
/// 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
|
||||
RegisterPollyOptimizer(llvm::PassManagerBuilder::EP_EarlyAsPossible,
|
||||
registerPollyEarlyAsPossiblePasses);
|
||||
RegisterPollyOptimizerEarly(llvm::PassManagerBuilder::EP_EarlyAsPossible,
|
||||
registerPollyEarlyAsPossiblePasses);
|
||||
|
||||
static llvm::RegisterStandardPasses
|
||||
RegisterPollyOptimizerLoopEnd(llvm::PassManagerBuilder::EP_LoopOptimizerEnd,
|
||||
registerPollyLoopOptimizerEndPasses);
|
||||
|
||||
static llvm::RegisterStandardPasses RegisterPollyOptimizerScalarLate(
|
||||
llvm::PassManagerBuilder::EP_VectorizerStart,
|
||||
registerPollyScalarOptimizerLatePasses);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user