summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-15 23:29:34 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-15 23:29:34 +0000
commit12821816c661f64623bb9cb507a05bb26ac813d7 (patch)
tree07aa73d1512d4d76fff2b5967d63e8fbd6e458ca
parentcb7554a3abbd89699284a5db0a4ebfa720e9cb89 (diff)
downloadbcm5719-llvm-12821816c661f64623bb9cb507a05bb26ac813d7.tar.gz
bcm5719-llvm-12821816c661f64623bb9cb507a05bb26ac813d7.zip
BumpPtrAllocator: Have the DefaultSlabAllocator created at runtime, not initialization time. This removes one of the 'init_constructors' reported in <rdar://problem/7545356>.
llvm-svn: 93581
-rw-r--r--llvm/include/llvm/Support/Allocator.h4
-rw-r--r--llvm/lib/Support/Allocator.cpp6
2 files changed, 6 insertions, 4 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index b0ed33d6ed5..496496b4c15 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -128,11 +128,11 @@ class BumpPtrAllocator {
/// one.
void DeallocateSlabs(MemSlab *Slab);
- static MallocSlabAllocator DefaultSlabAllocator;
+ static MallocSlabAllocator &GetDefaultSlabAllocator();
public:
BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096,
- SlabAllocator &allocator = DefaultSlabAllocator);
+ SlabAllocator &allocator = GetDefaultSlabAllocator());
~BumpPtrAllocator();
/// Reset - Deallocate all but the current slab and reset the current pointer
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 31b45c8d4aa..19d69f6f944 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/lib/Support/Allocator.cpp
@@ -142,8 +142,10 @@ void BumpPtrAllocator::PrintStats() const {
<< " (includes alignment, etc)\n";
}
-MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator =
- MallocSlabAllocator();
+MallocSlabAllocator &BumpPtrAllocator::GetDefaultSlabAllocator() {
+ static MallocSlabAllocator DefaultSlabAllocator;
+ return DefaultSlabAllocator;
+}
SlabAllocator::~SlabAllocator() { }
OpenPOWER on IntegriCloud