From f79b7835d821236a302090fa9eb05a3a1cc47c31 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 4 Dec 2015 23:48:19 +0000 Subject: [PATCH] [PassManager] Ensure destructors of cached AnalysisUsage objects are run 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 | 2 +- lib/IR/LegacyPassManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/llvm/IR/LegacyPassManagers.h b/include/llvm/IR/LegacyPassManagers.h index 418702c0b78..b8e33478d6a 100644 --- a/include/llvm/IR/LegacyPassManagers.h +++ b/include/llvm/IR/LegacyPassManagers.h @@ -283,7 +283,7 @@ private: // Allocator used for allocating UAFoldingSetNodes. This handles deletion of // all allocated nodes in one fell swoop. - BumpPtrAllocator AUFoldingSetNodeAllocator; + SpecificBumpPtrAllocator AUFoldingSetNodeAllocator; // Maps from a pass to it's associated entry in UniqueAnalysisUsages. Does // not own the storage associated with either key or value.. diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp index 08e8906e88d..f2e0c7d32c0 100644 --- a/lib/IR/LegacyPassManager.cpp +++ b/lib/IR/LegacyPassManager.cpp @@ -589,7 +589,7 @@ AnalysisUsage *PMTopLevelManager::findAnalysisUsage(Pass *P) { 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"); -- 2.34.1