summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/AllocatorTest.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-01 20:36:32 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-01 20:36:32 +0000
commit16558f4d3b532fe3da7f6910ad2de7af0322718a (patch)
tree7cb3306c354edf3a3f8991c2c892cac218b81ecd /llvm/unittests/Support/AllocatorTest.cpp
parent6b35c86fbe21c209aa436a78cac6b88428ddcb4c (diff)
downloadbcm5719-llvm-16558f4d3b532fe3da7f6910ad2de7af0322718a.tar.gz
bcm5719-llvm-16558f4d3b532fe3da7f6910ad2de7af0322718a.zip
If BumpPtrAllocator is requested to allocate a size that exceeds the slab size,
increase the slab size. llvm-svn: 151834
Diffstat (limited to 'llvm/unittests/Support/AllocatorTest.cpp')
-rw-r--r--llvm/unittests/Support/AllocatorTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/Support/AllocatorTest.cpp b/llvm/unittests/Support/AllocatorTest.cpp
index 6c0fca90456..bc5bd3dc407 100644
--- a/llvm/unittests/Support/AllocatorTest.cpp
+++ b/llvm/unittests/Support/AllocatorTest.cpp
@@ -93,6 +93,14 @@ TEST(AllocatorTest, TestOverflow) {
EXPECT_EQ(2U, Alloc.GetNumSlabs());
}
+// Test allocating with a size larger than the initial slab size.
+TEST(AllocatorTest, TestSmallSlabSize) {
+ BumpPtrAllocator Alloc(128);
+
+ Alloc.Allocate(200, 0);
+ EXPECT_EQ(1U, Alloc.GetNumSlabs());
+}
+
// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no
// easy portable way to do this, so this is kind of a hack.
class MockSlabAllocator : public SlabAllocator {
OpenPOWER on IntegriCloud