summaryrefslogtreecommitdiff
path: root/lib/Support/Allocator.cpp
Commit message (Collapse)AuthorAge
* [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
* [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] Replace some comparisons with 'nullptr' with simple boolean checks ↵Craig Topper2014-04-09
| | | | | | to reduce verbosity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205829 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
* [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] 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
* [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
* as the allocator is reset zero out the number of bytes allocated, this was justPedro Artigas2013-02-20
| | | | | | | missed before but probably what was intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175687 91177308-0d34-0410-b5e6-96231b3b80d8
* More MSan/ASan annotations.Evgeniy Stepanov2013-02-04
| | | | | | | | | | | | | | | This change lets us bootstrap LLVM/Clang under ASan and MSan. It contains fixes for 2 issues: - X86JIT reads return address from stack, which MSan does not know is initialized. - bugpoint tests run binaries with RLIMIT_AS. This does not work with certain Sanitizers. We are no longer including config.h in Compiler.h with this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174306 91177308-0d34-0410-b5e6-96231b3b80d8
* Annotate BumpPtrAllocator for MemorySanitizer.Evgeniy Stepanov2013-01-31
| | | | | | | | This change adds MemorySanitizer annotations to BumpPtrAllocator to improve report quality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174051 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* BumpPtrAllocator: Make sure threshold cannot be initialized with a value ↵Benjamin Kramer2012-03-01
| | | | | | | | smaller than the slab size. This replaces r151834 with a simpler fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151842 91177308-0d34-0410-b5e6-96231b3b80d8
* If BumpPtrAllocator is requested to allocate a size that exceeds the slab size,Argyrios Kyrtzidis2012-03-01
| | | | | | increase the slab size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151834 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
* 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
* Grow BumpPtrAllocator's slab size dynamically if we allocated many slabs. ThisBenjamin Kramer2010-09-30
| | | | | | | | | | | | | | | | | | | | | | reduces the amount of malloc calls and may reduce memory overhead. Some numbers: ASTContext stats, clang -cc1 -disable-free -fsyntax-only Cocoa_h.m without dynamic growth | with dynamic growth Number of memory regions: 3158 | Number of memory regions: 432 Bytes used: 12333185 | Bytes used: 12333185 Bytes allocated: 12935168 | Bytes allocated: 12800000 Bytes wasted: 601983 (includes alignment, etc) | Bytes wasted: 466815 (includes alignment, etc) ASTContext stats, clang -cc1 -disable-free -fsyntax-only on clang's ASTReader.cpp without dynamic growth | with dynamic growth Number of memory regions: 10987 | Number of memory regions: 551 Bytes used: 42910356 | Bytes used: 42910356 Bytes allocated: 45002752 | Bytes allocated: 44711936 Bytes wasted: 2092396 (includes alignment, etc) | Bytes wasted: 1801580 (includes alignment, etc) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115151 91177308-0d34-0410-b5e6-96231b3b80d8
* BumpPtrAllocator::Reset() doesn't need to allocate anything. (Thanks, Jakob)Benjamin Kramer2010-04-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101138 91177308-0d34-0410-b5e6-96231b3b80d8
* Let BumpPtrAllocator lazily allocate the first slab.Benjamin Kramer2010-04-13
| | | | | | | | We have some code in llvm and clang where a BumpPtrAllocator is declared in a class but never used in the common case. Stop wasting memory there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101130 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
* Introduce another Reset() method in BumpPtrAllocator that calls a destructorTorok Edwin2010-03-30
| | | | | | | | | | | on all objects it has allocated, if they are all of the same size and alignment. Use this to destruct all VNInfos allocated in LiveIntervalAnalysis (PR6653). valnos is not reliable for this purpose, as seen in r99400 (which still leaked, and sometimes caused double frees). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99881 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily revert r93581. It was causing failures in the ExecutionEngine testsBill Wendling2010-01-16
| | | | | | | on the build bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93606 91177308-0d34-0410-b5e6-96231b3b80d8
* BumpPtrAllocator: Have the DefaultSlabAllocator created at runtime, not ↵Ted Kremenek2010-01-15
| | | | | | initialization time. This removes one of the 'init_constructors' reported in <rdar://problem/7545356>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93581 91177308-0d34-0410-b5e6-96231b3b80d8
* Move DataTypes.h to include/llvm/System, update all users. This breaks the lastChandler Carruth2009-10-26
| | | | | | | direct inclusion edge from System to Support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85086 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure the memory range is writable before memset'ing it.Evan Cheng2009-09-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81308 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a test and fixed a bug in BumpPtrAllocator relating to large alignmentReid Kleckner2009-07-25
| | | | | | | values. Hopefully this fixes PR4622. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77088 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch to raw_ostream.Daniel Dunbar2009-07-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76943 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-committing changes from r76825 to BumpPtrAllocator with a fix and tests forReid Kleckner2009-07-23
| | | | | | | an off-by-one error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76891 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverting r76825 and r76828, since they caused clang runtime errors and some ↵Reid Kleckner2009-07-23
| | | | | | build failure involving memset. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76838 91177308-0d34-0410-b5e6-96231b3b80d8
* add header for 'memset'.Zhongxing Xu2009-07-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76837 91177308-0d34-0410-b5e6-96231b3b80d8
* Parameterize the BumpPtrAllocator over a slab allocator. It defaults to usingReid Kleckner2009-07-23
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76825 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold the useful features of alist and alist_node into ilist, andDan Gohman2008-07-28
| | | | | | | | | | | | | | | | | a new ilist_node class, and remove them. Unlike alist_node, ilist_node doesn't attempt to manage storage itself, so it avoids the associated problems, including being opaque in gdb. Adjust the Recycler class so that it doesn't depend on alist_node. Also, change it to use explicit Size and Align parameters, allowing it to work when the largest-sized node doesn't have the greatest alignment requirement. Change MachineInstr's MachineMemOperand list from a pool-backed alist to a std::list for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54146 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some basic Pool-allocation infrastructure. This adds a Recycler class,Dan Gohman2008-07-07
| | | | | | | | | for handling bookkeeping for deleted objects, as well as the alist class template, for keeping lists of objects allocated from Recyclers, and some related utilities. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53210 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix more -Wshorten-64-to-32 warnings.Evan Cheng2008-05-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a pointer-arithmetic bug that caused 64-bit host pointer values toDan Gohman2008-04-28
| | | | | | | | be truncated to 32 bits. This fixes the recent Benchmarks/McCat/09-vor regression on x86-64, among other things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50372 91177308-0d34-0410-b5e6-96231b3b80d8
* Bug fix in BumpPtrAllocator: don't assume that all objects have the same ↵Ted Kremenek2008-04-28
| | | | | | alignment. "Bump" of the pointer for the next allocated object to be of the specified alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50362 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
* Smarter Reset(). Instead of deallocating all memory regions and reallocate theEvan Cheng2007-09-08
| | | | | | | first region, just deallocate all but the last region in the list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41782 91177308-0d34-0410-b5e6-96231b3b80d8
* Added Reset() to free all allocated memory regions and reset state to be the ↵Evan Cheng2007-09-05
| | | | | | same as right after ctor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41728 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid TBAA issue.Chris Lattner2007-02-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34539 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use <sstream> in Streams.h but <iosfwd> instead.Bill Wendling2006-12-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32340 91177308-0d34-0410-b5e6-96231b3b80d8
* Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, areBill Wendling2006-12-07
| | | | | | | now cerr, cout, and NullStream resp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed #include <iostream> and replace with llvm_* streams.Bill Wendling2006-11-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31927 91177308-0d34-0410-b5e6-96231b3b80d8
* Include llvm/Support/DataTypes.h to define intptr_t.John Criswell2006-11-08
| | | | | | | This fixes the build on OpenBSD and potentially other systems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31550 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new llvm::Allocator abstraction, which will be used by a containerChris Lattner2006-10-29
I'm about to add. This is similar to, but necessarily different than, the STL allocator class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31285 91177308-0d34-0410-b5e6-96231b3b80d8