summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Allocator.h
Commit message (Collapse)AuthorAge
* Allocator: Remove ReferenceAdder hack.Benjamin Kramer2014-04-18
| | | | | | | This was a workaround for compilers that had issues with reference collapsing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206612 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Fix an obvious think-o with the move assignmentChandler Carruth2014-04-18
| | | | | | | implementation of the SpecificBumpPtrAllocator -- we have to actually move the subobject. =] Noticed when using this code more directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206582 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Make SpecificBumpPtrAllocator also movable and moveChandler Carruth2014-04-17
| | | | | | assignable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206448 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Make BumpPtrAllocator movable and move assignable.Chandler Carruth2014-04-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206372 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Nuke to useless functions. The implicit ones are sufficientChandler Carruth2014-04-16
| | | | | | here (obviously). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206369 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Fold the two templated overloads into a single one withChandler Carruth2014-04-15
| | | | | | | a default argument. The allocator interface we're modeling doesn't distinguish between array and non-array allocation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206327 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Remove a really problematic overload. This is very confusingChandler Carruth2014-04-15
| | | | | | | | | because there is another (size_t, size_t) overload of Allocator, and the only distinguishing factor is that one is a tempalte and the other isn't. There was only one usage of this and that one was easily converted to carry the alignment constraint in the type itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206325 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Finally, finish nuking the redundant code that led me hereChandler Carruth2014-04-15
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206267 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Pass the size to the deallocation function. This, on someChandler Carruth2014-04-15
| | | | | | | | | | | | allocation libraries, may allow more efficient allocation and deallocation. It at least makes the interface implementable by the JIT memory manager. However, this highlights problematic overloading between the void* and the T* deallocation functions. I'm looking into a better way to do this, but as it happens, it comes up rarely in the codebase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206265 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Fix r206256 which got the enabling case backwards on theseChandler Carruth2014-04-15
| | | | | | | | | | overloads. This doesn't matter *that* much yet, but it will in a subsequent patch. I had tested the original pattern, but not my attempt to pacify MSVC. This at least appears to work. Still fixing the rest of the fallout in the final patch that uses these overloads, but it will follow shortly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206259 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] MSVC apparantly has broken SFINAE context handling ofChandler Carruth2014-04-15
| | | | | | | | | | 'sizeof(T)' for T == void and produces a hard error. I cannot fathom why this is OK. Oh well. switch to an explicit test for being the (potentially qualified) void type, which is the only specific case I was worried about. Hopefully this survives the libstdc++ build bots which have limited type traits implementations... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206256 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Constrain the Deallocate templated overloads to only applyChandler Carruth2014-04-15
| | | | | | | | | | | to types which we can compute the size of. The comparison with zero isn't actually interesting here, it's mostly about putting sizeof into a sfinae context. This is particular important for Deallocate as otherwise the void* overload can quickly become ambiguous. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206251 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Add Deallocate support to the AllocatorBase CRTP class,Chandler Carruth2014-04-15
| | | | | | | | | | | | along with templated overloads much like we have for Allocate. These will facilitate switching the Deallocate interface of all the Allocator classes to accept the size by pre-filling it from the type size where we can do so. I plan to convert several uses to the template variants in subsequent patches prior to adding the Size parameter. No functionality changed, WIP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206230 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Hack around the fact that GCC can't compile theChandler Carruth2014-04-15
| | | | | | | static_assert added in r206225. I'm looking into a proper fix, but wanted the bots back. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206226 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Factor the Allocate template overloads into a base classChandler Carruth2014-04-15
| | | | | | | | | | | | | | | | | | | | rather than defining them (differently!) in both allocators. This also serves as a basis for documenting and even enforcing some of the LLVM-style "allocator" concept methods which must exist with various signatures. I plan on extending and changing the signatures of these to further simplify our allocator model in subsequent commits, so I wanted to factor things as best as I could first. Notably, I'm working to add the 'Size' to the deallocation method of all allocators. This has several implications not the least of which are faster deallocation times on certain allocation libraries (tcmalloc). It also will allow the JIT allocator to fully model the existing allocation interfaces and allow sanitizer poisoning of deallocated regions. The list of advantages goes on. =] But by factoring things first I'll be able to make this easier by first introducing template helpers for the deallocation path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206225 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Hoist the external helper function into a namespace scopeChandler Carruth2014-04-14
| | | | | | | declaration. GCC 4.7 appears to get hopelessly confused by declaring this function within a member function of a class template. Go figure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206152 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Make the underlying allocator a template instead of anChandler Carruth2014-04-14
| | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206149 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the compile from r206147 in release builds by moving a variableChandler Carruth2014-04-14
| | | | | | | declaration outside of #ifndef NDEBUG -- its used elsewhere. Sorry for the noise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206148 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Switch the BumpPtrAllocator to use a vector of pointers toChandler Carruth2014-04-14
| | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206147 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205697 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix MSVC warning.Rui Ueyama2014-03-31
| | | | | | | | | This patch is to fix the following warning when compiled with MSVC 64 bit. warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205245 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Lift the slab size and size threshold into templateChandler Carruth2014-03-30
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205143 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator Cleanup] Sink the private data members and methods to theChandler Carruth2014-03-28
| | | | | | | | | bottom of the interface to make it easier to scan and find the public API. No functionality changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204996 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator Cleanup] Move generic pointer alignment helper out of anChandler Carruth2014-03-28
| | | | | | | out-of-line private static method and into the collection of inline alignment helpers in MathExtras.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204995 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator Cleanup] Make the growth of the "slab" size of theChandler Carruth2014-03-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | BumpPtrAllocator significantly less strange by making it a simple function of the number of slabs allocated rather than by making it a recurrance. I *think* the previous behavior was essentially that the size of the slabs would be doubled after the first 128 were allocated, and then doubled again each time 64 more were allocated, but only if every allocation packed perfectly into the slab size. If not, the wasted space wouldn't be counted toward increasing the size, but allocations over the size threshold *would*. And since the allocations over the size threshold might be much larger than the slab size, this could have somewhat surprising consequences where we rapidly grow the slab size. This currently requires adding state to the allocator to track the number of slabs currently allocated, but that isn't too bad. I'm planning further changes to the allocator that will make this state fall out even more naturally. It still doesn't fully decouple the growth rate from the allocations which are over the size threshold. That fix is coming later. This specific fix will allow making the entire thing into a more stateless device and lifting the parameters into template parameters rather than runtime parameters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204993 91177308-0d34-0410-b5e6-96231b3b80d8
* [cleanup] Run clang-format over these routines to remove formattingChandler Carruth2014-03-27
| | | | | | | differences from subsequent diffs, and ease review. Going to be performing some major surgery to simplify this stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204908 91177308-0d34-0410-b5e6-96231b3b80d8
* [cleanup] Modernize doxygen comments for the BumpPtrAllocator andChandler Carruth2014-03-27
| | | | | | | | | | rewrite some of them to be more clear. The terminology being used in our allocators is making me really sad. We call things slab allocators that aren't at all slab allocators. It is quite confusing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204907 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword.Craig Topper2014-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203442 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202621 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix layering StringRef copy using BumpPtrAllocator.Nick Kledzik2014-02-05
| | | | | | | | | | | Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy: StringRef myCopy = myStr.copy(myAllocator); git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200885 91177308-0d34-0410-b5e6-96231b3b80d8
* Be more explicit about which overloaded variant to use. Caught by ASan!Nick Kledzik2014-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200353 91177308-0d34-0410-b5e6-96231b3b80d8
* fix templates to work with pre c++11Nick Kledzik2014-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200333 91177308-0d34-0410-b5e6-96231b3b80d8
* Add BumpPtrAllocator::allocateCopy() utilitiesNick Kledzik2014-01-28
| | | | | | | Makes it easy to use BumpPtrAllocator to make a copy of StringRef strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200331 91177308-0d34-0410-b5e6-96231b3b80d8
* [BumpPtrAllocator] Move DefaultSlabAllocator to a member of ↵Argyrios Kyrtzidis2013-08-28
| | | | | | | | | | BumpPtrAllocator, instead of a static variable. The problem with having DefaultSlabAllocator being a global static is that it is undefined if BumpPtrAllocator will be usable during global initialization because it is not guaranteed that DefaultSlabAllocator will be initialized before BumpPtrAllocator is created and used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189433 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort the #include lines for the include/... tree with the script.Chandler Carruth2012-12-03
| | | | | | | | | | AKA: Recompile *ALL* the source code! This one went much better. No manual edits here. I spot-checked for silliness and grep-checked for really broken edits and everything seemed good. It all still compiles. Yell if you see something that looks goofy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169133 91177308-0d34-0410-b5e6-96231b3b80d8
* Add LLVM_OVERRIDE to methods that override their base classes.Craig Topper2012-09-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164471 91177308-0d34-0410-b5e6-96231b3b80d8
* Use LLVM_DELETED_FUNCTION for copy constructors and copy assignment ↵Craig Topper2012-09-16
| | | | | | operators that aren't implemented. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164006 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r159789.Dmitri Gribenko2012-07-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159834 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable new[] on llvm::BumpPtrAllocator.Dmitri Gribenko2012-07-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159789 91177308-0d34-0410-b5e6-96231b3b80d8
* Add BumpPtrAllocator::getTotalMemory() to allow clients to query how much ↵Ted Kremenek2011-04-18
| | | | | | memory a BumpPtrAllocator allocated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129727 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance ScopedHashTable to allow it to take an allocator argument.Chris Lattner2011-01-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122721 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge System into Support.Michael J. Spencer2010-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename alignof -> alignOf to avoid irritating C++'0x compilers,Chris Lattner2010-10-30
| | | | | | | | PR8423, patch by nobled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117774 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove two uses of the gcc specific 'aligned' attribute. ThisDuncan Sands2010-10-03
| | | | | | | | | | | | is partly because this attribute caused trouble in the past (the SmallVector one had to be changed from aligned to aligned(8) due to causing crashes on i386 for example; in theory the same might be needed in the Allocator case...). But it's mostly because there seems to be no point in special casing gcc here. Using the same implementation for all compilers results in better testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115462 91177308-0d34-0410-b5e6-96231b3b80d8
* Provide operator delete for BumpPtrAllocator and RecyclingAllocator. They willBenjamin Kramer2010-04-08
| | | | | | | never be called but msvc complains that they're missing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100766 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch SSEDomainFix to SpecificBumpPtrAllocator.Jakob Stoklund Olesen2010-04-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100332 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix SpecificBumpPtrAllocator iteration.Torok Edwin2010-04-02
| | | | | | | | | Need to start from (char*)(Slab+1), and not from (char*)Slab+1. This fixes crashes in Win64 debug mode. Thanks to Nicolas Capens! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100184 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce SpecificBumpPtrAllocator, a wrapper for BumpPtrAllocator which allowsBenjamin Kramer2010-03-30
| | | | | | | | only a single type of object to be allocated. Use it to make VNInfo destruction typesafe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99919 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r99881 with some fixes: only call destructor in releaseMemory!Torok Edwin2010-03-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99883 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert 99881, it brooke smooshlab's llvm-gcc-i386-darwin9.Torok Edwin2010-03-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99882 91177308-0d34-0410-b5e6-96231b3b80d8