Do now allow InlineAlways pass to remove dead functions.
authorDevang Patel <dpatel@apple.com>
Wed, 5 Nov 2008 01:39:16 +0000 (01:39 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 5 Nov 2008 01:39:16 +0000 (01:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58744 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO/InlinerPass.h
lib/Transforms/IPO/InlineAlways.cpp
lib/Transforms/IPO/Inliner.cpp

index 082dd82a67ec6011aa6f689f4b8809d99d07f2c0..7c3632fdce111ba2fd6e930f7da0774ed862e012 100644 (file)
@@ -61,6 +61,10 @@ struct Inliner : public CallGraphSCCPass {
   ///
   virtual float getInlineFudgeFactor(CallSite CS) = 0;
 
+  /// removeDeadFunctions - Remove dead functions that are not included in
+  /// DNR (Do Not Remove) list.
+  bool removeDeadFunctions(CallGraph &CG, 
+                           SmallPtrSet<const Function *, 16> *DNR = NULL);
 private:
   // InlineThreshold - Cache the value here for easy access.
   unsigned InlineThreshold;
index d809b5aed173d8d56fc269bf1f536f6754d1b6a7..9031432162e07b2970e098a8f9264c6d84257a12 100644 (file)
@@ -45,6 +45,9 @@ namespace {
     float getInlineFudgeFactor(CallSite CS) {
       return CA.getInlineFudgeFactor(CS);
     }
+    virtual bool doFinalization(CallGraph &CG) { 
+      return removeDeadFunctions(CG, &NeverInline); 
+    }
     virtual bool doInitialization(CallGraph &CG);
   };
 }
index 2321047a3758e6e5a72a73175976b4e203ae82f7..418b2b70cb66a96afc059b52a3371efc0ab4a3fe 100644 (file)
@@ -204,6 +204,13 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
 // doFinalization - Remove now-dead linkonce functions at the end of
 // processing to avoid breaking the SCC traversal.
 bool Inliner::doFinalization(CallGraph &CG) {
+  return removeDeadFunctions(CG);
+}
+
+  /// removeDeadFunctions - Remove dead functions that are not included in
+  /// DNR (Do Not Remove) list.
+bool Inliner::removeDeadFunctions(CallGraph &CG, 
+                                 SmallPtrSet<const Function *, 16> *DNR) {
   std::set<CallGraphNode*> FunctionsToRemove;
 
   // Scan for all of the functions, looking for ones that should now be removed
@@ -215,6 +222,9 @@ bool Inliner::doFinalization(CallGraph &CG) {
       // them.
       F->removeDeadConstantUsers();
 
+      if (DNR && DNR->count(F))
+        continue;
+
       if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
           F->use_empty()) {