[PATCH] Support to lazily load Metadata

Rafael Espíndola rafael.espindola at gmail.com
Fri Mar 13 10:33:30 PDT 2015


BTW, changing llvm-ar to use this makes producing lib64/libclangSema.a
in a debug build go from  8.658015807 seconds to just 0.351036519
seconds :-)

On 13 March 2015 at 12:49, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
> This is awesome. Sorry for taking so long to review it.
>
> +  // Delay parsing Metadata if WillMaterializeAll is false and
> +  // ShouldLazyLoadMetadata is true.
> +  if (std::error_code EC = R->ParseBitcodeInto(
> +          M, !WillMaterializeAll && ShouldLazyLoadMetadata))
>
> Why the check for WillMaterializeAll? The nice thing about omitting it
> is that the lazy path will look a bit more like the non-lazy path.
>
> It looks like a materializeMetadata will be needed for the gold
> plugin, but I can add that as a second patch. LGTM!
>
> Thanks,
> Rafael
>
>
>
> On 27 February 2015 at 14:11, Manman Ren <mren at apple.com> wrote:
>> Hi All,
>>
>> This patch defers loading of Metadata until we materialize a module, a function or explicitly the Metadata.
>>
>> In this patch, we only enable lazy loading of Metadata when creating LTOModule in local contexts.
>> These can only really be used for parsing symbols, so it's unnecessary to ever load the metadata blocks.
>>
>> Implementation —————
>> We add a parameter called ShouldLazyLoadMetadata to a few functions.
>>
>> We only defer loading metadata inside ParseModule when ShouldLazyLoadMetadata
>> is true and we have not loaded any Metadata block yet.
>>
>> This commit implements all-or-nothing loading of Metadata. If there is a
>> request to load any metadata block, we will load all deferred metadata blocks.
>>
>> We make sure the deferred metadata blocks are loaded before we materialize any
>> function or a module.
>>
>> The default value of the added parameter ShouldLazyLoadMetadata for
>> getLazyBitcodeModule is false, so the default behavior stays the same.
>>
>> Next Step —————
>> If we are going to enable lazy-loading of Metadata for other usages of
>> getLazyBitcodeModule, where deferred metadata blocks need to be loaded, we can
>> expose BitcodeReader::materializeMetadata to Module, similar to
>> Module::materialize.
>>
>> Thanks for reviewing!
>> Manman
>>




More information about the llvm-commits mailing list