Clear CachedFunctionInfo upon Pass::releaseMemory. Because ValueMap will abort
authorNick Lewycky <nicholas@mxc.ca>
Wed, 12 May 2010 21:48:15 +0000 (21:48 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 12 May 2010 21:48:15 +0000 (21:48 +0000)
on RAUW of functions, this is a correctness issue instead of a mere memory
usage problem.

No testcase until the new MergeFunctions can land.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103653 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d51dd6cbd6fd097c5107a2dbf65fdf1dd8b6029a..cac7cfe2455e943649aa90ac5fe0f23d1dd564de 100644 (file)
@@ -198,6 +198,9 @@ namespace llvm {
     /// has been inlined. If Callee is NULL it means a dead call has been
     /// eliminated.
     void growCachedCostInfo(Function* Caller, Function* Callee);
+
+    /// clear - empty the cache of inline costs
+    void clear();
   };
 
   /// callIsSmall - If a call is likely to lower to a single target instruction,
index 627137159706097616ff93f8af2ac191e363f9d8..10c2d79bef3d4dd7d5651757af7459cf7b0d4006 100644 (file)
@@ -455,6 +455,11 @@ InlineCostAnalyzer::growCachedCostInfo(Function *Caller, Function *Callee) {
   else
     CallerMetrics.NumInsts = 0;
   
-  // We are not updating the argumentweights. We have already determined that
+  // We are not updating the argument weights. We have already determined that
   // Caller is a fairly large function, so we accept the loss of precision.
 }
+
+/// clear - empty the cache of inline costs
+void InlineCostAnalyzer::clear() {
+  CachedFunctionInfo.clear();
+}
index 46cf4b25e42b031a3c8b9137d861f21a8b759cb5..74b4a1c10ece200cbb384fca8a1513c4e072984f 100644 (file)
@@ -49,6 +49,9 @@ namespace {
       CA.growCachedCostInfo(Caller, Callee);
     }
     virtual bool doInitialization(CallGraph &CG);
+    void releaseMemory() {
+      CA.clear();
+    }
   };
 }