[cfe-dev] Instrumenting the run-time sizes of SmallVector et al.

Hans Wennborg hans at chromium.org
Sun Aug 10 19:23:26 PDT 2014


I've always wondered how the in-line sizes of SmallVector,
SmallString, etc. that we use in LLVM and Clang hold up against the
actual sizes of the containers at run-time.

To figure this out, I added a destructor to each such class, that
would dump the container's final size into a table that got printed at
exit. I also added a special field, __clang_ObjectLocation, to each
such class and hacked Clang to populate that field with the source
location of the object's declarator each time its constructor was
called.

I used this instrumented compiler to build vanilla Clang and captured
the results (attached, along with the patches I used). It looks like
we mostly get it right, but I have patches for a few size tweaks I'd
like to do. (The measurements were done on Clang r215325 / LLVM
r215315).

Cheers,
Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.patch
Type: text/x-patch
Size: 2837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140810/84f35bc2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm_adt.patch
Type: text/x-patch
Size: 6422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140810/84f35bc2/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: results.txt.gz
Type: application/x-gzip
Size: 25657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140810/84f35bc2/attachment-0002.bin>


More information about the cfe-dev mailing list