[LLVMdev] Stupid question about BumpPtrAllocator

Chris Lattner clattner at apple.com
Wed Jul 16 11:08:34 PDT 2008


On Jul 16, 2008, at 10:12 AM, Jonathan Brumley wrote:

>
> I'll preface by saying I'm new to LLVM -
>
> I noticed there is an efficient BumpPtrAllocator - however, I can't  
> figure out how I can allocate IR objects using that allocator.  It  
> looks like all the factory methods use regular new/delete.
>
> I'm sure someone BumpPtrAllocator is there for a good reason, and  
> someone here has thought of this use case before.  Anyone want to  
> comment?  Is this a bad idea?  Do the optimization passes generate a  
> ton of garbage that needs to be cleaned up immediately?
>
> Or would it be reasonably safe to use the BumpPtrAllocator during IR  
> creation, optimization, and codegen, and just delete all the garbage  
> when done with codegen?

Unfortunately, LLVM IR objects don't allow you to allocate them with a  
custom allocator right now, sorry!  Generally optimization passes  
produce transient data from maps on the side and other data structures  
they build.  This sort of data *is* very useful to use an allocator for.

-Chris



More information about the llvm-dev mailing list