[PATCH] Bitcode: Try to emit metadata in function blocks

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 17:41:08 PDT 2016

Whenever metadata is only referenced by a single function, emit the
metadata just in that function block.  This should improve lazy-loading
by reducing the amount of metadata in the global block.

For now, this should catch all DILocations, and anything else that
happens to be referenced only by a single function.

It's also a first step toward a couple of possible future directions
(which this commit does *not* implement):

 1. Some debug info metadata is only referenced from compile units and
    individual functions.  If we can drop the link from the compile
    unit, this optimization will get more powerful.

 2. Any uniqued metadata that isn't referenced globally can in theory be
    emitted in every function block that references it (trading off
    bitcode size and full-parse time vs. lazy-load time).

Note: the only change on the reader side is cautious error checking.
The metadata stored in function blocks gets purged after parsing each
function, which means unresolved forward references will get lost.
Since all the global metadata should have already been resolved by the
time we get to the function metadata blocks we just need to check for
that case.  (If for some reason we need this, the fix is to store
about-to-be-dropped unresolved nodes in MetadataList::shrinkTo until
they can be handled succesfully by a future call to

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Bitcode-Try-to-emit-metadata-in-function-blocks-v3.patch
Type: application/octet-stream
Size: 20900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160327/470454d4/attachment.obj>

More information about the llvm-commits mailing list