[PATCH] BumpPtr allocate SimpleReferences

kledzik at apple.com kledzik at apple.com
Wed Dec 3 17:13:04 PST 2014


Hi ruiu, Jean-Daniel, shankar.easwaran,

The mach-o part of lld has a leak because it BumpPtr allocates SimpleDefinedAtoms.  The problem is SimpleDefinedAtom has a ivar that is a vector of SimpleReferences.  Since BumpPtr allocated objects are not destructed, the allocations done in the vector are leaked.

This fix is to add a BumpPtrAllocator to the base lld::File class and alter SimpleDefinedAtom to allocate its SimpleReference in the BumpPtr pool.  The mess is that vectors don't BumpPtrAllocate well, so I switched to using a linked list (llvm::ilist<>) for the SimpleReference.

I tried adding the BumpPtrAllocator instead to some subclasses of lld::File, but failed because a handful of places add SimpleDefinedAtom to lots of different subclasses of File. And since the general model is that Atoms are owned by their File, it makes sense to have an allocator in the File for allocating various objects related to the file or atoms (e.g. strings).

http://reviews.llvm.org/D6518

Files:
  include/lld/Core/File.h
  include/lld/Core/Simple.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6518.16901.patch
Type: text/x-patch
Size: 7727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141204/5cbe2265/attachment.bin>


More information about the llvm-commits mailing list