summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2017-03-08 23:55:33 +0000
committerJessica Paquette <jpaquette@apple.com>2017-03-08 23:55:33 +0000
commitd4cb9c6da0b940e0b13c1c5a286cc67d31267d70 (patch)
tree6f6f27b830899e0afaad9fd45f8e954a35d2fa41 /llvm/lib
parent935b2a36540049c2780a193a1728387cf94bbacf (diff)
downloadbcm5719-llvm-d4cb9c6da0b940e0b13c1c5a286cc67d31267d70.tar.gz
bcm5719-llvm-d4cb9c6da0b940e0b13c1c5a286cc67d31267d70.zip
[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. llvm-svn: 297319
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 0ce5539f020..8b950580061 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -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;
OpenPOWER on IntegriCloud