summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/AllocatorTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [unittest] Explicitly specify alignment when using BumpPtrAllocator.Jordan Rose2017-03-111-3/+3
| | | | | | | | | | | | | r297310 began inserting red zones around allocations under ASan, which perturbs the alignment of subsequent allocations. Deliberately specify this in two places where it matters. Fixes failures when these tests are run under ASan and UBSan together. Reviewed by Duncan Exon Smith. rdar://problem/30980047 llvm-svn: 297540
* Fix "the the" in comments.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240112
* Fix llvm::BumpPtrAllocatorImpl::Reset()Hans Wennborg2015-05-181-0/+7
| | | | | | | | BumpPtrAllocator's Reset wouldn't clear CustomSizedSlabs if Slabs.size() == 0. Patch by Kal <b17c0de@gmail.com>! llvm-svn: 237588
* Try to unflake AllocatorTest.TestAlignmentPastSlabHans Wennborg2014-09-071-3/+4
| | | | llvm-svn: 217331
* BumpPtrAllocator: do the size check without moving any pointersHans Wennborg2014-09-071-0/+12
| | | | | | | | | | | | | Instead of aligning and moving the CurPtr forward, and then comparing with End, simply calculate how much space is needed, and compare that to how much is available. Hopefully this avoids any doubts about comparing addresses possibly derived from past the end of the slab array, overflowing, etc. Also add a test where aligning CurPtr would move it past End. llvm-svn: 217330
* BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined ↵Hans Wennborg2014-09-021-1/+1
| | | | | | | | | behaviour In theory, alignPtr() could push a pointer beyond the end of the current slab, making comparisons with that pointer undefined behaviour. Use an integer type to avoid this. llvm-svn: 216973
* BumpPtrAllocator: don't accept 0 for the alignment parameterHans Wennborg2014-08-191-14/+14
| | | | | | | | It seems unnecessary to have to use an extra branch to check for this special case. http://reviews.llvm.org/D4945 llvm-svn: 216036
* BumpPtrAllocator: remove 'no slabs allocated yet' checkHans Wennborg2014-08-171-1/+1
| | | | | | | | | | 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
* [Allocator] Make BumpPtrAllocator movable and move assignable.Chandler Carruth2014-04-161-0/+15
| | | | llvm-svn: 206372
* [Allocator] Finally, finish nuking the redundant code that led me hereChandler Carruth2014-04-151-1/+1
| | | | | | | | | | | | | | | | by removing the MallocSlabAllocator entirely and just using MallocAllocator directly. This makes all off these allocators expose and utilize the same core interface. The only ugly part of this is that it exposes the fact that the JIT allocator has no real handling of alignment, any more than the malloc allocator does. =/ It would be nice to fix both of these to support alignments, and then to leverage that in the BumpPtrAllocator to do less over allocation in order to manually align pointers. But, that's another patch for another day. This patch has no functional impact, it just removes the somewhat meaningless wrapper around MallocAllocator. llvm-svn: 206267
* [Allocator] Make the underlying allocator a template instead of anChandler Carruth2014-04-141-9/+10
| | | | | | | | | | | | abstract interface. The only user of this functionality is the JIT memory manager and it is quite happy to have a custom type here. This removes a virtual function call and a lot of unnecessary abstraction from the common case where this is just a *very* thin vaneer around a call to malloc. Hopefully still no functionality changed here. =] llvm-svn: 206149
* [Allocator] Switch the BumpPtrAllocator to use a vector of pointers toChandler Carruth2014-04-141-16/+18
| | | | | | | | | | | | | | | | | | | | | | | slabs rather than embedding a singly linked list in the slabs themselves. This has a few advantages: - Better utilization of the slab's memory by not wasting 16-bytes at the front. - Simpler allocation strategy by not having a struct packed at the front. - Avoids paging every allocated slab in just to traverse them for deallocating or dumping stats. The latter is the really nice part. Folks have complained from time to time bitterly that tearing down a BumpPtrAllocator, even if it doesn't run any destructors, pages in all of the memory allocated. Now it won't. =] Also resolves a FIXME with the scaling of the slab sizes. The scaling now disregards specially sized slabs for allocations larger than the threshold. llvm-svn: 206147
* [Allocator] Lift the slab size and size threshold into templateChandler Carruth2014-03-301-1/+1
| | | | | | | | | | parameters rather than runtime parameters. There is only one user of these parameters and they are compile time for that user. Making these compile time seems to better reflect their intended usage as well. llvm-svn: 205143
* [Allocator] Simplify unittests by using the default size parameters inChandler Carruth2014-03-301-5/+5
| | | | | | more places. llvm-svn: 205141
* Fix layering StringRef copy using BumpPtrAllocator.Nick Kledzik2014-02-051-28/+0
| | | | | | | | | Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy: StringRef myCopy = myStr.copy(myAllocator); llvm-svn: 200885
* Add BumpPtrAllocator::allocateCopy() utilitiesNick Kledzik2014-01-281-0/+28
| | | | | | Makes it easy to use BumpPtrAllocator to make a copy of StringRef strings. llvm-svn: 200331
* Sort the #include lines for unittest/...Chandler Carruth2012-12-041-1/+0
| | | | llvm-svn: 169250
* BumpPtrAllocator: Make sure threshold cannot be initialized with a value ↵Benjamin Kramer2012-03-011-1/+1
| | | | | | | | smaller than the slab size. This replaces r151834 with a simpler fix. llvm-svn: 151842
* If BumpPtrAllocator is requested to allocate a size that exceeds the slab size,Argyrios Kyrtzidis2012-03-011-0/+8
| | | | | | increase the slab size. llvm-svn: 151834
* Spelling fixes.Dan Gohman2010-03-011-1/+1
| | | | llvm-svn: 97454
* Fix unit test on FreeBSD. We need to make sure there is enough space to save ↵Benjamin Kramer2009-08-121-1/+1
| | | | | | the pointer even if the memory returned from malloc was already aligned. llvm-svn: 78805
* Added a test and fixed a bug in BumpPtrAllocator relating to large alignmentReid Kleckner2009-07-251-0/+48
| | | | | | values. Hopefully this fixes PR4622. llvm-svn: 77088
* Re-committing changes from r76825 to BumpPtrAllocator with a fix and tests forReid Kleckner2009-07-231-0/+95
| | | | | | an off-by-one error. llvm-svn: 76891
* Reverting r76825 and r76828, since they caused clang runtime errors and some ↵Reid Kleckner2009-07-231-61/+0
| | | | | | build failure involving memset. llvm-svn: 76838
* Parameterize the BumpPtrAllocator over a slab allocator. It defaults to usingReid Kleckner2009-07-231-0/+61
malloc, so there should be no functional changes to other code. These changes are necessary since I have plans to use this allocator in the JIT memory manager, and it needs a special allocator. I also added some tests which helped me pinpoint some bugs. llvm-svn: 76825
OpenPOWER on IntegriCloud