[PATCH] Change MCTextAtom to use std::list instead of std::vector

Chandler Carruth chandlerc at google.com
Tue Oct 15 13:04:38 PDT 2013


On Tue, Oct 15, 2013 at 12:31 PM, Stephen Checkoway <s at pahtak.org> wrote:

>
> On Oct 15, 2013, at 2:43 PM, Chandler Carruth <chandlerc at google.com>
> wrote:
>
> > Have you looked into the LLVM ilist? Its intrusive and so should be a
> touch faster and a touch more memory dense than std::list.
>
> I hadn't looked at it before. This would require adding next and prev
> pointers to MCDecodedInst? Unless I'm missing something, wouldn't this
> result in exactly the same memory usage.
>
> list<MCDecodedInst> has nodes of type _List_node<MCDecodedInst> which is a
> subclass of __detail::_List_node_base so it should have three members:
> _List_node_base *_M_next
> _List_node_base *_M_prev
> MCDecodedInst _M_data
> (at least using libstdc++).
>
> That should have the same memory usage, no?
>
> As a sanity check,
>
> #include <llvm/MC/MCAtom.h>
> #include <cstdio>
> #include <list>
>
> int main()
> {
>   printf("%zu\n", alignof(llvm::MCDecodedInst));
>   printf("%zu\n", sizeof(llvm::MCDecodedInst));
>   printf("%zu\n", sizeof(typename std::list<llvm::MCDecodedInst>::_Node));
>   return 0;
> }
>
> prints 8, 184, 200 for 64-bit and 4, 132, 140 for 64-bit.
>
> Where do you see memory improvements?
>

Typically, fragmentation and alignment. It seems we're lucky with the
alignment though.

Maybe it doesn't matter for your use case. Many of LLVM's types use ilist
and have benefitted from it, so I at least wanted to see if you had checked.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131015/c6a6f570/attachment.html>


More information about the llvm-commits mailing list