Revert r98089, it was breaking a clang test.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 9 Mar 2010 22:43:37 +0000 (22:43 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 9 Mar 2010 22:43:37 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98094 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f0e97d7a181b4527052298790567080ba6dda3e6..84acd7d5fee979f29a6796873432cc2ceac1edd6 100644 (file)
@@ -179,11 +179,6 @@ namespace llvm {
     void resetCachedCostInfo(Function* Caller) {
       CachedFunctionInfo[Caller] = FunctionInfo();
     }
-
-    /// growCachedCostInfo - update the cached cost info for Caller after Callee
-    /// has been inlined. If Callee is NULL it means a dead call has been
-    /// eliminated.
-    void growCachedCostInfo(Function* Caller, Function* Callee);
   };
 }
 
index c5be59a8cd7f0dffb25ee9409a17efa41a22e179..30ece0eb422f1601d953e91d8b1fdbcfbc33351d 100644 (file)
@@ -75,10 +75,6 @@ struct Inliner : public CallGraphSCCPass {
   /// 
   virtual void resetCachedCostInfo(Function* Caller) = 0;
 
-  /// growCachedCostInfo - update the cached cost info for Caller after Callee
-  /// has been inlined.
-  virtual void growCachedCostInfo(Function* Caller, Function* Callee) = 0;
-
   /// removeDeadFunctions - Remove dead functions that are not included in
   /// DNR (Do Not Remove) list.
   bool removeDeadFunctions(CallGraph &CG, 
index 09e66487c7a66be0ec25f7e31969ade68c3b0113..140e7daa6d331304c0bc28e810c4000e95d165cb 100644 (file)
@@ -383,39 +383,3 @@ float InlineCostAnalyzer::getInlineFudgeFactor(CallSite CS) {
     Factor += 1.5f;
   return Factor;
 }
-
-/// growCachedCostInfo - update the cached cost info for Caller after Callee has
-/// been inlined.
-void
-InlineCostAnalyzer::growCachedCostInfo(Function* Caller, Function* Callee) {
-  FunctionInfo &CallerFI = CachedFunctionInfo[Caller];
-
-  // For small functions we prefer to recalculate the cost for better accuracy.
-  if (!CallerFI.Metrics.NumBlocks || CallerFI.Metrics.NumInsts < 100) {
-    resetCachedCostInfo(Caller);
-    return;
-  }
-
-  // For large functions, we can save a lot of computation time by skipping
-  // recalculations.
-  if (CallerFI.Metrics.NumCalls > 0)
-    --CallerFI.Metrics.NumCalls;
-
-  if (Callee) {
-    FunctionInfo &CalleeFI = CachedFunctionInfo[Callee];
-    if (!CalleeFI.Metrics.NumBlocks) {
-      resetCachedCostInfo(Caller);
-      return;
-    }
-    CallerFI.Metrics.NeverInline |= CalleeFI.Metrics.NeverInline;
-    CallerFI.Metrics.usesDynamicAlloca |= CalleeFI.Metrics.usesDynamicAlloca;
-
-    CallerFI.Metrics.NumInsts += CalleeFI.Metrics.NumInsts;
-    CallerFI.Metrics.NumBlocks += CalleeFI.Metrics.NumBlocks;
-    CallerFI.Metrics.NumCalls += CalleeFI.Metrics.NumCalls;
-    CallerFI.Metrics.NumVectorInsts += CalleeFI.Metrics.NumVectorInsts;
-    CallerFI.Metrics.NumRets += CalleeFI.Metrics.NumRets;
-  }
-  // We are not updating the argumentweights. We have already determined that
-  // Caller is a fairly large function, so we accept the loss of precision.
-}
index bc8028c020a158f15e5bbffcb836ab2f8ecb675e..f11ecae8dfc907f78540a0ee2445573b2b42abc2 100644 (file)
@@ -45,10 +45,7 @@ namespace {
       return CA.getInlineFudgeFactor(CS);
     }
     void resetCachedCostInfo(Function *Caller) {
-      CA.resetCachedCostInfo(Caller);
-    }
-    void growCachedCostInfo(Function* Caller, Function* Callee) {
-      CA.growCachedCostInfo(Caller, Callee);
+      return CA.resetCachedCostInfo(Caller);
     }
     virtual bool doFinalization(CallGraph &CG) { 
       return removeDeadFunctions(CG, &NeverInline); 
index 46cf4b25e42b031a3c8b9137d861f21a8b759cb5..598043de694a69046b905010054cb2179443403f 100644 (file)
@@ -45,9 +45,6 @@ namespace {
     void resetCachedCostInfo(Function *Caller) {
       CA.resetCachedCostInfo(Caller);
     }
-    void growCachedCostInfo(Function* Caller, Function* Callee) {
-      CA.growCachedCostInfo(Caller, Callee);
-    }
     virtual bool doInitialization(CallGraph &CG);
   };
 }
index 03ec72c0304323ae3cd8ca535dc26201b90ec2a1..3d0309f87cf950ba0d2ab258ab1bed72421df571 100644 (file)
@@ -369,8 +369,6 @@ bool Inliner::runOnSCC(std::vector<CallGraphNode*> &SCC) {
         CG[Caller]->removeCallEdgeFor(CS);
         CS.getInstruction()->eraseFromParent();
         ++NumCallsDeleted;
-        // Update the cached cost info with the missing call
-        growCachedCostInfo(Caller, NULL);
       } else {
         // We can only inline direct calls to non-declarations.
         if (Callee == 0 || Callee->isDeclaration()) continue;
@@ -384,9 +382,6 @@ bool Inliner::runOnSCC(std::vector<CallGraphNode*> &SCC) {
         if (!InlineCallIfPossible(CS, CG, TD, InlinedArrayAllocas))
           continue;
         ++NumInlined;
-
-        // Update the cached cost info with the inlined call.
-        growCachedCostInfo(Caller, Callee);
       }
       
       // If we inlined or deleted the last possible call site to the function,
@@ -412,6 +407,11 @@ bool Inliner::runOnSCC(std::vector<CallGraphNode*> &SCC) {
         delete CG.removeFunctionFromModule(CalleeNode);
         ++NumDeleted;
       }
+      
+      // Remove any cached cost info for this caller, as inlining the
+      // callee has increased the size of the caller (which may be the
+      // same as the callee).
+      resetCachedCostInfo(Caller);
 
       // Remove this call site from the list.  If possible, use 
       // swap/pop_back for efficiency, but do not use it if doing so would