[llvm-commits] [llvm-gcc-4.2] r72795 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp

Daniel Dunbar daniel at zuster.org
Wed Jun 3 12:03:17 PDT 2009


Author: ddunbar
Date: Wed Jun  3 14:03:17 2009
New Revision: 72795

URL: http://llvm.org/viewvc/llvm-project?rev=72795&view=rev
Log:
Pull out code to create the appropriate InliningPass.
 - No functionality change.

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

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=72795&r1=72794&r2=72795&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jun  3 14:03:17 2009
@@ -632,26 +632,31 @@
   PerModulePasses = new PassManager();
   PerModulePasses->add(new TargetData(*TheTarget->getTargetData()));
   bool HasPerModulePasses = false;
-  bool NeedAlwaysInliner = false;
-  if (flag_inline_trees <= 1) {
-    // If full inliner is not run, check if always-inline is needed to handle
-    // functions that are  marked as always_inline.
-    for (Module::iterator I = TheModule->begin(), E = TheModule->end();
-         I != E; ++I)
-      if (I->hasFnAttr(Attribute::AlwaysInline)) {
-        NeedAlwaysInliner = true;
-        break;
-      }
-  }
 
   if (!DisableLLVMOptimizations) {
+    bool NeedAlwaysInliner = false;
+    llvm::Pass *InliningPass = 0;
+    if (flag_inline_trees > 1) {                // respect -fno-inline-functions
+      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.
+      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;
     PassManager *PM = PerModulePasses;
     if (optimize == 0) {
-      if (flag_inline_trees > 1)                // respect -fno-inline-functions
-        PM->add(createFunctionInliningPass());    // Inline small functions
-      else if (NeedAlwaysInliner)
-        PM->add(createAlwaysInlinerPass());       // Inline always_inline funcs
+      if (InliningPass)
+        PM->add(InliningPass);
     } else {
       if (flag_unit_at_a_time)
         PM->add(createRaiseAllocationsPass());    // call %malloc -> malloc inst
@@ -670,10 +675,8 @@
           PM->add(createPruneEHPass());           // Remove dead EH info
         PM->add(createFunctionAttrsPass());       // Deduce function attrs
       }
-      if (flag_inline_trees > 1)                // respect -fno-inline-functions
-        PM->add(createFunctionInliningPass());    // Inline small functions
-      else if (NeedAlwaysInliner)
-        PM->add(createAlwaysInlinerPass());       // Inline always_inline funcs
+      if (InliningPass)
+        PM->add(InliningPass);
       if (optimize > 2)
         PM->add(createArgumentPromotionPass());   // Scalarize uninlined fn args
       if (!flag_no_simplify_libcalls)





More information about the llvm-commits mailing list