[llvm-commits] [llvm] r58744 - in /llvm/trunk: include/llvm/Transforms/IPO/InlinerPass.h lib/Transforms/IPO/InlineAlways.cpp lib/Transforms/IPO/Inliner.cpp

Devang Patel dpatel at apple.com
Tue Nov 4 17:39:16 PST 2008


Author: dpatel
Date: Tue Nov  4 19:39:16 2008
New Revision: 58744

URL: http://llvm.org/viewvc/llvm-project?rev=58744&view=rev
Log:
Do now allow InlineAlways pass to remove dead functions.

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

Modified: llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h?rev=58744&r1=58743&r2=58744&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h Tue Nov  4 19:39:16 2008
@@ -61,6 +61,10 @@
   ///
   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;

Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=58744&r1=58743&r2=58744&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Tue Nov  4 19:39:16 2008
@@ -45,6 +45,9 @@
     float getInlineFudgeFactor(CallSite CS) {
       return CA.getInlineFudgeFactor(CS);
     }
+    virtual bool doFinalization(CallGraph &CG) { 
+      return removeDeadFunctions(CG, &NeverInline); 
+    }
     virtual bool doInitialization(CallGraph &CG);
   };
 }

Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=58744&r1=58743&r2=58744&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Nov  4 19:39:16 2008
@@ -204,6 +204,13 @@
 // 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 @@
       // them.
       F->removeDeadConstantUsers();
 
+      if (DNR && DNR->count(F))
+        continue;
+
       if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
           F->use_empty()) {
 





More information about the llvm-commits mailing list