[llvm] r297319 - [Outliner] Fix memory leak in suffix tree.
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 15:55:33 PST 2017
Author: paquette
Date: Wed Mar 8 17:55:33 2017
New Revision: 297319
URL: http://llvm.org/viewvc/llvm-project?rev=297319&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/MachineOutliner.cpp
Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=297319&r1=297318&r2=297319&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Wed Mar 8 17:55:33 2017
@@ -222,7 +222,7 @@ private:
ArrayRef<unsigned> Str;
/// Maintains each node in the tree.
- BumpPtrAllocator NodeAllocator;
+ SpecificBumpPtrAllocator<SuffixTreeNode> 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;
More information about the llvm-commits
mailing list