[LLVMdev] How to reduce the footprint of MDNodes? (About the comment you made at BOF LTO)

Chandler Carruth chandlerc at google.com
Tue Nov 12 13:28:11 PST 2013


On Mon, Nov 11, 2013 at 11:29 PM, Chris Lattner <clattner at apple.com> wrote:

> Hi Manman (and llvmdev),
>
> I filed these two bugs to track the ideas that I was cooking:
>
> http://llvm.org/bugs/show_bug.cgi?id=17891
> http://llvm.org/bugs/show_bug.cgi?id=17892
>
> TL;DR: I'm saying we should go from:
>
>         !14 = metadata !{i32 786445, metadata !1, metadata !10, metadata
> !"y", i32 3, i64 32, i64 32, i64 32, i32 0, metadata !13}
> to:
>         !14 = metadata !"v12,14,y,3,0,32,32,32"(metadata !1, metadata !13)
>

So, I like where you're going here, but a few tweaks.

First, there are two things going on here: removing an indirection through
a referenced metadata node and flattening N values into a string inclusion.
Removing the indirection seems obvious strict goodness, my comments are
about the second part.

I'm moderately opposed to just encoding these in a string format. I think
we can do something substantially better both for space, time, and
readability. Fundamentally, there is no reason for the original metadata
node you describe to not *encode* its operands into a dense bit-packed blob
of memory. We can still expose APIs that manipulate them as separate
entities, and have the AsmPrinter and AsmParser map back and forth with
nice human-readable forms. But even a simple varint encoding will be both
smaller and faster than ascii.

Just to be clear, I still want the nice format (much like your proposed
format, but maybe with the numbers outside of the "s) in the textual IR, I
just think we should use a more direct and efficient in-memory encoding
(and in-bitcode encoding if that isn't already suitably dense).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131112/9d6086ce/attachment.html>


More information about the llvm-dev mailing list