[llvm-commits] [polly] r146560 - in /polly/trunk: lib/RegisterPasses.cpp www/example_load_Polly_into_clang.html

Tobias Grosser grosser at fim.uni-passau.de
Wed Dec 14 04:21:31 PST 2011


Author: grosser
Date: Wed Dec 14 06:21:31 2011
New Revision: 146560

URL: http://llvm.org/viewvc/llvm-project?rev=146560&view=rev
Log:
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'

Modified:
    polly/trunk/lib/RegisterPasses.cpp
    polly/trunk/www/example_load_Polly_into_clang.html

Modified: polly/trunk/lib/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/RegisterPasses.cpp?rev=146560&r1=146559&r2=146560&view=diff
==============================================================================
--- polly/trunk/lib/RegisterPasses.cpp (original)
+++ polly/trunk/lib/RegisterPasses.cpp Wed Dec 14 06:21:31 2011
@@ -109,36 +109,8 @@
 
 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 @@
   //           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 llvm::RegisterStandardPasses
 PassRegister(llvm::PassManagerBuilder::EP_EarlyAsPossible,
              registerPollyPasses);
+static llvm::RegisterStandardPasses
+PassRegisterPreopt(llvm::PassManagerBuilder::EP_EnabledOnOptLevel0,
+                   registerPollyPreoptPasses);

Modified: polly/trunk/www/example_load_Polly_into_clang.html
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/example_load_Polly_into_clang.html?rev=146560&r1=146559&r2=146560&view=diff
==============================================================================
--- polly/trunk/www/example_load_Polly_into_clang.html (original)
+++ polly/trunk/www/example_load_Polly_into_clang.html Wed Dec 14 06:21:31 2011
@@ -59,6 +59,16 @@
 
 <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





More information about the llvm-commits mailing list