[ThinLTO] Fix lazy-loading of Metadata attachment, which left some Fwd ref behind

The change in r291362 was too agressive. We still need to flush at the
end of the block because function local metadata can introduce fwd
ref as well.
(Bootstrap with ThinLTO was broken)

llvm-svn: 291379
This commit is contained in:
Mehdi Amini 2017-01-08 00:44:45 +00:00
parent 04060ab619
commit 7b0d145768
1 changed files with 2 additions and 1 deletions

View File

@ -1561,6 +1561,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(
return error("Invalid record");
SmallVector<uint64_t, 64> Record;
PlaceholderQueue Placeholders;
while (true) {
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
@ -1570,6 +1571,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(
case BitstreamEntry::Error:
return error("Malformed block");
case BitstreamEntry::EndBlock:
resolveForwardRefsAndPlaceholders(Placeholders);
return Error::success();
case BitstreamEntry::Record:
// The interesting case.
@ -1608,7 +1610,6 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(
!MetadataList.lookup(Idx)) {
// Load the attachment if it is in the lazy-loadable range and hasn't
// been loaded yet.
PlaceholderQueue Placeholders;
lazyLoadOneMetadata(Idx, Placeholders);
resolveForwardRefsAndPlaceholders(Placeholders);
}