[llvm-commits] [gcc-plugin] r83260 - /gcc-plugin/trunk/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Sat Oct 3 07:00:25 PDT 2009


Author: baldrick
Date: Sat Oct  3 09:00:25 2009
New Revision: 83260

URL: http://llvm.org/viewvc/llvm-project?rev=83260&view=rev
Log:
Due to a thoughtless search-and-replace of flag_inline_trees
with "2" (like was done in gcc mainline) the full LLVM inliner
was being run at all optimization levels, including -O0.  Only
run the inliner at -O2 or above.

Modified:
    gcc-plugin/trunk/llvm-backend.cpp

Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=83260&r1=83259&r2=83260&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Sat Oct  3 09:00:25 2009
@@ -726,8 +726,24 @@
   bool HasPerModulePasses = false;
 
   if (!DisableLLVMOptimizations) {
-    // Inline small functions.
-    llvm::Pass *InliningPass = createFunctionInliningPass();
+    bool NeedAlwaysInliner = false;
+    llvm::Pass *InliningPass = 0;
+    if (optimize >= 2) {
+      InliningPass = createFunctionInliningPass();    // Inline small functions
+    } else {
+      // If full inliner is not run, check if always-inline is needed to handle
+      // functions that are  marked as always_inline.
+      // TODO: Consider letting the GCC inliner do this.
+      for (Module::iterator I = TheModule->begin(), E = TheModule->end();
+           I != E; ++I)
+        if (I->hasFnAttr(Attribute::AlwaysInline)) {
+          NeedAlwaysInliner = true;
+          break;
+        }
+
+      if (NeedAlwaysInliner)
+        InliningPass = createAlwaysInlinerPass();  // Inline always_inline funcs
+    }
 
     HasPerModulePasses = true;
     createStandardModulePasses(PerModulePasses, optimize,





More information about the llvm-commits mailing list