From: Jessica Paquette Date: Wed, 8 Mar 2017 23:55:33 +0000 (+0000) Subject: [Outliner] Fix memory leak in suffix tree. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94a8180da701c4dc6ca925a21255b86a327ac0b6;p=llvm [Outliner] Fix memory leak in suffix tree. This commit changes the BumpPtrAllocator for suffix tree nodes to a SpecificBumpPtrAllocator. Before, node construction was leaking memory because of the DenseMap in SuffixTreeNodes. Changing this to a SpecificBumpPtrAllocator allows this memory to properly be released. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297319 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineOutliner.cpp b/lib/CodeGen/MachineOutliner.cpp index 0ce5539f020..8b950580061 100644 --- a/lib/CodeGen/MachineOutliner.cpp +++ b/lib/CodeGen/MachineOutliner.cpp @@ -222,7 +222,7 @@ private: ArrayRef Str; /// Maintains each node in the tree. - BumpPtrAllocator NodeAllocator; + SpecificBumpPtrAllocator NodeAllocator; /// The root of the suffix tree. /// @@ -274,10 +274,10 @@ private: assert(StartIdx <= LeafEndIdx && "String can't start after it ends!"); - SuffixTreeNode *N = new (NodeAllocator) SuffixTreeNode(StartIdx, - &LeafEndIdx, - nullptr, - &Parent); + SuffixTreeNode *N = new (NodeAllocator.Allocate()) SuffixTreeNode(StartIdx, + &LeafEndIdx, + nullptr, + &Parent); Parent.Children[Edge] = N; return N; @@ -299,10 +299,10 @@ private: "Non-root internal nodes must have parents!"); size_t *E = new (InternalEndIdxAllocator) size_t(EndIdx); - SuffixTreeNode *N = new (NodeAllocator) SuffixTreeNode(StartIdx, - E, - Root, - Parent); + SuffixTreeNode *N = new (NodeAllocator.Allocate()) SuffixTreeNode(StartIdx, + E, + Root, + Parent); if (Parent) Parent->Children[Edge] = N;