mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 04:46:27 +08:00
Allow to run the Polly preopt passes with -O0
To extract a preoptimized LLVM-IR file from a C-file run: clang -Xclang -load -Xclang LLVMPolly.so -O0 -mllvm -polly file.c -S -emit-llvm On the generated file you can directly run passes such as: 'opt -view-scops file.s' llvm-svn: 146560
This commit is contained in:
@@ -109,36 +109,8 @@ public:
|
||||
|
||||
static StaticInitializer InitializeEverything;
|
||||
|
||||
static void registerPollyPasses(const llvm::PassManagerBuilder &Builder,
|
||||
llvm::PassManagerBase &PM) {
|
||||
if (PollyOnlyPrinter || PollyPrinter || PollyOnlyViewer || PollyViewer ||
|
||||
ExportJScop || ImportJScop)
|
||||
PollyEnabled = true;
|
||||
|
||||
if (!PollyEnabled) {
|
||||
if (DisableCodegen)
|
||||
errs() << "The option -polly-no-codegen has no effect. "
|
||||
"Polly was not enabled\n";
|
||||
|
||||
if (DisableScheduler)
|
||||
errs() << "The option -polly-no-optimizer has no effect. "
|
||||
"Polly was not enabled\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Polly is only enabled at -O3
|
||||
if (Builder.OptLevel != 3) {
|
||||
errs() << "Polly should only be run with -O3. Disabling Polly.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
bool RunScheduler = !DisableScheduler;
|
||||
bool RunCodegen = !DisableCodegen;
|
||||
|
||||
|
||||
|
||||
|
||||
static void registerPollyPreoptPasses(const llvm::PassManagerBuilder &Builder,
|
||||
llvm::PassManagerBase &PM) {
|
||||
// A standard set of optimization passes partially taken/copied from the
|
||||
// set of default optimization passes. It is used to bring the code into
|
||||
// a canonical form that can than be analyzed by Polly. This set of passes is
|
||||
@@ -168,6 +140,40 @@ static void registerPollyPasses(const llvm::PassManagerBuilder &Builder,
|
||||
// recover them
|
||||
PM.add(llvm::createIndVarSimplifyPass());
|
||||
PM.add(polly::createRegionSimplifyPass());
|
||||
}
|
||||
|
||||
static void registerPollyPasses(const llvm::PassManagerBuilder &Builder,
|
||||
llvm::PassManagerBase &PM) {
|
||||
|
||||
if (Builder.OptLevel == 0)
|
||||
return;
|
||||
|
||||
if (PollyOnlyPrinter || PollyPrinter || PollyOnlyViewer || PollyViewer ||
|
||||
ExportJScop || ImportJScop)
|
||||
PollyEnabled = true;
|
||||
|
||||
if (!PollyEnabled) {
|
||||
if (DisableCodegen)
|
||||
errs() << "The option -polly-no-codegen has no effect. "
|
||||
"Polly was not enabled\n";
|
||||
|
||||
if (DisableScheduler)
|
||||
errs() << "The option -polly-no-optimizer has no effect. "
|
||||
"Polly was not enabled\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Polly is only enabled at -O3
|
||||
if (Builder.OptLevel != 3) {
|
||||
errs() << "Polly should only be run with -O3. Disabling Polly.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
bool RunScheduler = !DisableScheduler;
|
||||
bool RunCodegen = !DisableCodegen;
|
||||
|
||||
registerPollyPreoptPasses(Builder, PM);
|
||||
|
||||
if (PollyViewer)
|
||||
PM.add(polly::createDOTViewerPass());
|
||||
@@ -216,3 +222,6 @@ static void registerPollyPasses(const llvm::PassManagerBuilder &Builder,
|
||||
static llvm::RegisterStandardPasses
|
||||
PassRegister(llvm::PassManagerBuilder::EP_EarlyAsPossible,
|
||||
registerPollyPasses);
|
||||
static llvm::RegisterStandardPasses
|
||||
PassRegisterPreopt(llvm::PassManagerBuilder::EP_EnabledOnOptLevel0,
|
||||
registerPollyPreoptPasses);
|
||||
|
||||
@@ -59,6 +59,16 @@ Automatic vector code generation can be enabled by adding <b>-mllvm
|
||||
|
||||
<pre class="code">pollycc -O3 -mllvm -enable-polly-vector file.c</pre>
|
||||
|
||||
<h2>Extract a preoptimized LLVM-IR file</h2>
|
||||
|
||||
Often it is useful to derive from a C-file the LLVM-IR code that is actually
|
||||
optimized by Polly. Normally the LLVM-IR is automatically generated from
|
||||
the C code by first lowering C to LLVM-IR (clang) and by subsequently applying a
|
||||
set of preparing transformations on the LLVM-IR. To get the LLVM-IR after the
|
||||
preparing transformations have been applied run Polly with '-O0'.
|
||||
|
||||
<pre class="code">pollycc -O0 -mllvm -polly -S -emit-llvm file.c</pre>
|
||||
|
||||
<h2>Further options</h2>
|
||||
|
||||
Polly supports further options that are mainly useful for the development or
|
||||
|
||||
Reference in New Issue
Block a user