From 67c59826bf0c2e980130781d1ea0d6b062e4b659 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 15 Jan 2010 23:29:34 +0000 Subject: BumpPtrAllocator: Have the DefaultSlabAllocator created at runtime, not initialization time. This removes one of the 'init_constructors' reported in . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93581 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Allocator.h | 4 ++-- lib/Support/Allocator.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index b0ed33d6ed..496496b4c1 100644 --- a/include/llvm/Support/Allocator.h +++ b/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/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 31b45c8d4a..19d69f6f94 100644 --- a/lib/Support/Allocator.cpp +++ b/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() { } -- cgit v1.2.3