Add BranchProbabilityInfo::releaseMemory to clear the Weights field.
authorPete Cooper <peter_cooper@apple.com>
Thu, 28 May 2015 19:43:06 +0000 (19:43 +0000)
committerPete Cooper <peter_cooper@apple.com>
Thu, 28 May 2015 19:43:06 +0000 (19:43 +0000)
BranchProbabilityInfo was leaking 3MB of memory when running 'opt -O2 verify-uselistorder.lto.bc'.  This was due to the Weights member not being cleared once the pass is no longer needed.

This adds the releaseMemory override to clear that field.  The other fields are cleared at the end of runOnFunction so can stay there.

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

include/llvm/Analysis/BranchProbabilityInfo.h
lib/Analysis/BranchProbabilityInfo.cpp

index 89eef68d84316890baef9e632e03220b48f48b02..9d867567ba2942e70af9ce6705881d00f0252fc1 100644 (file)
@@ -47,6 +47,9 @@ public:
 
   void getAnalysisUsage(AnalysisUsage &AU) const override;
   bool runOnFunction(Function &F) override;
+
+  void releaseMemory() override;
+
   void print(raw_ostream &OS, const Module *M = nullptr) const override;
 
   /// \brief Get an edge's probability, relative to other out-edges of the Src.
index 091943bfc7b3aa3f474256c3622b789c3733e9b6..430b41241edf59bcd26d2247079096de27c41e5a 100644 (file)
@@ -543,6 +543,10 @@ bool BranchProbabilityInfo::runOnFunction(Function &F) {
   return false;
 }
 
+void BranchProbabilityInfo::releaseMemory() {
+  Weights.clear();
+}
+
 void BranchProbabilityInfo::print(raw_ostream &OS, const Module *) const {
   OS << "---- Branch Probabilities ----\n";
   // We print the probabilities from the last function the analysis ran over,