[llvm-commits] [see] CVS: llvm/lib/Transforms/IPO/Inliner.cpp

John Criswell criswell at cs.uiuc.edu
Fri Apr 6 08:14:20 PDT 2007



Changes in directory llvm/lib/Transforms/IPO:

Inliner.cpp updated: 1.30.2.1 -> 1.30.2.1.2.1
---
Log message:

Adde dthe no-inline option to force the inliner not to inline specified
functions.


---
Diffs of the changes:  (+25 -1)

 Inliner.cpp |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/Inliner.cpp
diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.30.2.1 llvm/lib/Transforms/IPO/Inliner.cpp:1.30.2.1.2.1
--- llvm/lib/Transforms/IPO/Inliner.cpp:1.30.2.1	Thu Nov  9 18:06:24 2006
+++ llvm/lib/Transforms/IPO/Inliner.cpp	Fri Apr  6 10:14:03 2007
@@ -33,9 +33,24 @@
   cl::opt<unsigned>             // FIXME: 200 is VERY conservative
   InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
         cl::desc("Control the amount of inlining to perform (default = 200)"));
+
+  // NoInlineList - A list of functions that should *not* be inlined,
+  //                regardless of inlining policy
+  cl::list<std::string>
+  NoInlineList("no-inline", cl::value_desc("list"),
+          cl::desc("A list of functions that should not be inlined"),
+          cl::CommaSeparated);
+
+  // A set of the functions to preserve
+  std::set<std::string> PreserveFuncs;
 }
 
-Inliner::Inliner() : InlineThreshold(InlineLimit) {}
+Inliner::Inliner() : InlineThreshold(InlineLimit) {
+ // Create a set that contains a list of the functions that will not be
+ // inlined.
+ if (!(NoInlineList.empty()))
+  PreserveFuncs.insert (NoInlineList.begin(), NoInlineList.end());
+}
 
 // InlineCallIfPossible - If it is possible to inline the specified call site,
 // do so and update the CallGraph for this operation.
@@ -123,6 +138,15 @@
           continue;
         }
 
+        // Do not inline functions that we have explicity said we don't want to
+        // inline.
+        if (!PreserveFuncs.count ((Callee->getName()))) {
+          std::swap(CallSites[CSi], CallSites.back());
+          CallSites.pop_back();
+          --CSi;
+          continue;
+        }
+
         // If the policy determines that we should inline this function,
         // try to do so.
         CallSite CS = CallSites[CSi];






More information about the llvm-commits mailing list