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

Stephen Checkoway s at pahtak.org
Tue Oct 15 12:31:20 PDT 2013


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?

-- 
Stephen Checkoway









More information about the llvm-commits mailing list