[dragonegg] r183431 - When LLVM optimization is explicitly turned off, don't run the always-inliner

Duncan Sands baldrick at free.fr
Thu Jun 6 11:43:18 PDT 2013


Author: baldrick
Date: Thu Jun  6 13:43:17 2013
New Revision: 183431

URL: http://llvm.org/viewvc/llvm-project?rev=183431&view=rev
Log:
When LLVM optimization is explicitly turned off, don't run the always-inliner
either as the user almost certainly wants the raw bitcode as it is before it
hits the optimizers.  While there, add a missing addAnalysisPasses.

Modified:
    dragonegg/trunk/src/Backend.cpp
    dragonegg/trunk/test/validator/c/NoIROptimize.c

Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=183431&r1=183430&r2=183431&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Thu Jun  6 13:43:17 2013
@@ -698,6 +698,7 @@ static void createPerFunctionOptimizatio
   // FIXME: Move the code generator to be function-at-a-time.
   PerFunctionPasses = new FunctionPassManager(TheModule);
   PerFunctionPasses->add(new DataLayout(TheModule));
+  TheTarget->addAnalysisPasses(*PerFunctionPasses);
 
 #ifndef NDEBUG
   PerFunctionPasses->add(createVerifierPass());
@@ -746,8 +747,10 @@ static void createPerModuleOptimizationP
   TheTarget->addAnalysisPasses(*PerModulePasses);
 
   bool NeedAlwaysInliner = false;
-  llvm::Pass *InliningPass = 0;
-  if (LLVMIROptimizeArg && flag_inline_small_functions && !flag_no_inline) {
+  Pass *InliningPass;
+  if (!LLVMIROptimizeArg)
+    InliningPass = 0;
+  else if (flag_inline_small_functions && !flag_no_inline) {
     // Inline small functions.  Figure out a reasonable threshold to pass llvm's
     // inliner.  GCC has many options that control inlining, but we have decided
     // not to support anything like that for dragonegg.
@@ -772,8 +775,7 @@ static void createPerModuleOptimizationP
         break;
       }
 
-    if (NeedAlwaysInliner)
-      InliningPass = createAlwaysInlinerPass(); // Inline always_inline funcs
+    InliningPass = NeedAlwaysInliner ? createAlwaysInlinerPass() : 0;
   }
 
   PassBuilder.OptLevel = ModuleOptLevel();

Modified: dragonegg/trunk/test/validator/c/NoIROptimize.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/NoIROptimize.c?rev=183431&r1=183430&r2=183431&view=diff
==============================================================================
--- dragonegg/trunk/test/validator/c/NoIROptimize.c (original)
+++ dragonegg/trunk/test/validator/c/NoIROptimize.c Thu Jun  6 13:43:17 2013
@@ -1,3 +1,7 @@
 // RUN: %dragonegg -S -O3 -fplugin-arg-dragonegg-llvm-ir-optimize=0 -fplugin-arg-dragonegg-debug-pass-arguments %s 2>&1 | FileCheck %s
 
 // CHECK-NOT: inline
+
+inline __attribute__ ((__always_inline__)) void foo(void) {}
+void bar(void) { foo(); }
+void qaz(void) { bar(); }





More information about the llvm-commits mailing list