[PATCH] D28113: Use lazy-loading of Metadata in MetadataLoader when importing is enabled (NFC)

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 25 22:41:30 PST 2016


mehdi_amini created this revision.
mehdi_amini added reviewers: pcc, tejohnson, dexonsmith.
mehdi_amini added a subscriber: llvm-commits.

This is a relatively simple scheme: we use the index emitted in the
bitcode to avoid loading all the global metadata. Instead we load
the index with their position in the bitcode so that we can load each
of them individually. Materializing the global metadata block in this
condition only triggers loading the named metadata, and the ones
referenced from there (transitively). When materializing a function,
metadatas from the global block are loaded lazily as they are
referenced.

Two main current limitations are:

1. Global values other than functions are not materialized on demand,

so we need to eagerly load METADATA_GLOBAL_DECL_ATTACHMENT records
(and their transitive dependencies).

2. When we load a single metadata, we don't recurse on the operands,

instead we use a placeholder or a temporary metadata. Unfortunately
tepmorary nodes are very expensive. This is why we don't have it
always enabled and only for importing.

These two limitations can be lifted in a subsequent improvement if
needed.

With this change, the total link time of opt with ThinLTO and Debug
Info enabled is going down from 282s to 224s (~20%).


https://reviews.llvm.org/D28113

Files:
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Transforms/IPO/FunctionImport.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28113.82490.patch
Type: text/x-patch
Size: 22228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161226/04019b21/attachment.bin>


More information about the llvm-commits mailing list