summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Allocator.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-28 01:02:21 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-28 01:02:21 +0000
commitaae63a0ce6099396dcc18348672e8aaeb25d1d93 (patch)
tree1c326c479b08c5c63b53695a9463b429d132d430 /llvm/lib/Support/Allocator.cpp
parent9bfa2e2e7fd475642dd2953e7739a4f06f74a6db (diff)
downloadbcm5719-llvm-aae63a0ce6099396dcc18348672e8aaeb25d1d93.tar.gz
bcm5719-llvm-aae63a0ce6099396dcc18348672e8aaeb25d1d93.zip
[BumpPtrAllocator] Move DefaultSlabAllocator to a member of BumpPtrAllocator, instead of a static variable.
The problem with having DefaultSlabAllocator being a global static is that it is undefined if BumpPtrAllocator will be usable during global initialization because it is not guaranteed that DefaultSlabAllocator will be initialized before BumpPtrAllocator is created and used. llvm-svn: 189433
Diffstat (limited to 'llvm/lib/Support/Allocator.cpp')
-rw-r--r--llvm/lib/Support/Allocator.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 3c4191b805a..6e7a541dd4b 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/lib/Support/Allocator.cpp
@@ -26,6 +26,10 @@ BumpPtrAllocator::BumpPtrAllocator(size_t size, size_t threshold,
: SlabSize(size), SizeThreshold(std::min(size, threshold)),
Allocator(allocator), CurSlab(0), BytesAllocated(0) { }
+BumpPtrAllocator::BumpPtrAllocator(size_t size, size_t threshold)
+ : SlabSize(size), SizeThreshold(std::min(size, threshold)),
+ Allocator(DefaultSlabAllocator), CurSlab(0), BytesAllocated(0) { }
+
BumpPtrAllocator::~BumpPtrAllocator() {
DeallocateSlabs(CurSlab);
}
@@ -167,9 +171,6 @@ void BumpPtrAllocator::PrintStats() const {
<< " (includes alignment, etc)\n";
}
-MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator =
- MallocSlabAllocator();
-
SlabAllocator::~SlabAllocator() { }
MallocSlabAllocator::~MallocSlabAllocator() { }
OpenPOWER on IntegriCloud