[llvm] r254795 - Address a memory leak in 254760

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 15:06:33 PST 2015


Author: reames
Date: Fri Dec  4 17:06:33 2015
New Revision: 254795

URL: http://llvm.org/viewvc/llvm-project?rev=254795&view=rev
Log:
Address a memory leak in 254760

The issue appears to have been that the copy constructor of the SmallVector was being invoked and this was somehow leading to leaked memory.  This patch avoids the symptom, but likely doesn't address the underlying problem.  I'm still investigating the root cause, but wanted to avoid the memory leak in the mean time.  Even with the underlying fix, avoiding the redundant allocation is worthwhile.


Modified:
    llvm/trunk/include/llvm/IR/LegacyPassManagers.h

Modified: llvm/trunk/include/llvm/IR/LegacyPassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LegacyPassManagers.h?rev=254795&r1=254794&r2=254795&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/LegacyPassManagers.h (original)
+++ llvm/trunk/include/llvm/IR/LegacyPassManagers.h Fri Dec  4 17:06:33 2015
@@ -264,12 +264,15 @@ private:
       // TODO: We could consider sorting the dependency arrays within the
       // AnalysisUsage (since they are conceptually unordered).
       ID.AddBoolean(AU.getPreservesAll());
-      for (auto &Vec : {AU.getRequiredSet(), AU.getRequiredTransitiveSet(),
-            AU.getPreservedSet(), AU.getUsedSet()}) {
+      auto ProfileVec = [&](const SmallVectorImpl<AnalysisID>& Vec) {
         ID.AddInteger(Vec.size());
         for(AnalysisID AID : Vec)
           ID.AddPointer(AID);
-      }
+      };
+      ProfileVec(AU.getRequiredSet());
+      ProfileVec(AU.getRequiredTransitiveSet());
+      ProfileVec(AU.getPreservedSet());
+      ProfileVec(AU.getUsedSet());
     }
   };
 




More information about the llvm-commits mailing list