[PassManager] Ensure destructors of cached AnalysisUsage objects are run
authorPhilip Reames <listmail@philipreames.com>
Fri, 4 Dec 2015 23:48:19 +0000 (23:48 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 4 Dec 2015 23:48:19 +0000 (23:48 +0000)
In 254760, I introduced the usage of a BumpPtrAllocator for the AnalysisUsage instances held by the PassManger.  This turns out to have been incorrect since a BumpPtrAllocator does not run the destructors of objects when deallocating memory.  Since a few of our SmallVector's had grown beyond their small size, we end up with some leaked memory.  We need to use a SpecificBumpPtrAllocator instead.

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

include/llvm/IR/LegacyPassManagers.h
lib/IR/LegacyPassManager.cpp

index 418702c0b781ae1a481e783c1424f42e7138697c..b8e33478d6a9d3666db8076ffcbb270c75bbd31d 100644 (file)
@@ -283,7 +283,7 @@ private:
   
   // Allocator used for allocating UAFoldingSetNodes.  This handles deletion of
   // all allocated nodes in one fell swoop.
   
   // Allocator used for allocating UAFoldingSetNodes.  This handles deletion of
   // all allocated nodes in one fell swoop.
-  BumpPtrAllocator AUFoldingSetNodeAllocator;
+  SpecificBumpPtrAllocator<AUFoldingSetNode> AUFoldingSetNodeAllocator;
   
   // Maps from a pass to it's associated entry in UniqueAnalysisUsages.  Does
   // not own the storage associated with either key or value.. 
   
   // Maps from a pass to it's associated entry in UniqueAnalysisUsages.  Does
   // not own the storage associated with either key or value.. 
index 08e8906e88db08afbeb73aa42bb0e2c36dddcf27..f2e0c7d32c0209ea8ca666b15a120adb12291344 100644 (file)
@@ -589,7 +589,7 @@ AnalysisUsage *PMTopLevelManager::findAnalysisUsage(Pass *P) {
     if (auto *N = UniqueAnalysisUsages.FindNodeOrInsertPos(ID, IP))
       Node = N;
     else {
     if (auto *N = UniqueAnalysisUsages.FindNodeOrInsertPos(ID, IP))
       Node = N;
     else {
-      Node = new (AUFoldingSetNodeAllocator) AUFoldingSetNode(AU);
+      Node = new (AUFoldingSetNodeAllocator.Allocate()) AUFoldingSetNode(AU);
       UniqueAnalysisUsages.InsertNode(Node, IP);
     }
     assert(Node && "cached analysis usage must be non null");
       UniqueAnalysisUsages.InsertNode(Node, IP);
     }
     assert(Node && "cached analysis usage must be non null");