Skip to content

Commit d47b1d7

Browse files
committed
BumpPtrAllocator: remove 'no slabs allocated yet' check
We already handle the no-slabs case when checking whether the current slab is large enough: if no slabs have been allocated, CurPtr and End are both 0. alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails. Differential Revision: http://reviews.llvm.org/D4943 llvm-svn: 215841
1 parent 52d23d4 commit d47b1d7

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

llvm/include/llvm/Support/Allocator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ class BumpPtrAllocatorImpl
201201

202202
/// \brief Allocate space at the specified alignment.
203203
void *Allocate(size_t Size, size_t Alignment) {
204-
if (!CurPtr) // Start a new slab if we haven't allocated one already.
205-
StartNewSlab();
206-
207204
// Keep track of how many bytes we've allocated.
208205
BytesAllocated += Size;
209206

llvm/unittests/Support/AllocatorTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ TEST(AllocatorTest, TestSmallSlabSize) {
112112
BumpPtrAllocator Alloc;
113113

114114
Alloc.Allocate(8000, 0);
115-
EXPECT_EQ(2U, Alloc.GetNumSlabs());
115+
EXPECT_EQ(1U, Alloc.GetNumSlabs());
116116
}
117117

118118
// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no

0 commit comments

Comments
 (0)