Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 94a8180

Browse files
author
Jessica Paquette
committed
[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
1 parent 9dd9f4f commit 94a8180

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/CodeGen/MachineOutliner.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class SuffixTree {
222222
ArrayRef<unsigned> Str;
223223

224224
/// Maintains each node in the tree.
225-
BumpPtrAllocator NodeAllocator;
225+
SpecificBumpPtrAllocator<SuffixTreeNode> NodeAllocator;
226226

227227
/// The root of the suffix tree.
228228
///
@@ -274,10 +274,10 @@ class SuffixTree {
274274

275275
assert(StartIdx <= LeafEndIdx && "String can't start after it ends!");
276276

277-
SuffixTreeNode *N = new (NodeAllocator) SuffixTreeNode(StartIdx,
278-
&LeafEndIdx,
279-
nullptr,
280-
&Parent);
277+
SuffixTreeNode *N = new (NodeAllocator.Allocate()) SuffixTreeNode(StartIdx,
278+
&LeafEndIdx,
279+
nullptr,
280+
&Parent);
281281
Parent.Children[Edge] = N;
282282

283283
return N;
@@ -299,10 +299,10 @@ class SuffixTree {
299299
"Non-root internal nodes must have parents!");
300300

301301
size_t *E = new (InternalEndIdxAllocator) size_t(EndIdx);
302-
SuffixTreeNode *N = new (NodeAllocator) SuffixTreeNode(StartIdx,
303-
E,
304-
Root,
305-
Parent);
302+
SuffixTreeNode *N = new (NodeAllocator.Allocate()) SuffixTreeNode(StartIdx,
303+
E,
304+
Root,
305+
Parent);
306306
if (Parent)
307307
Parent->Children[Edge] = N;
308308

0 commit comments

Comments
 (0)