From d5549f3dacea43baedb09f874763141bd3ac24e6 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 7 Jan 2017 20:24:23 +0000 Subject: [ThinLTO] Fix assertions on lazy-loading of Metadata TBAA attachments Summary: The issue happens with: %0 = ....., !tbaa !0 %1 = ....., !tbaa !1 With !0 that references !1. In this case when loading !0 we generates a temporary for the operand !1. We now flush it immediately and trigger the load of !1 before moving on. If we don't we get the temporary when attaching to %1. This is usually not an issue except that we eagerly try to update TBAA MDNodes, which is obviously not possible if we only have a temporary. Differential Revision: https://reviews.llvm.org/D28423 llvm-svn: 291362 --- llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp') diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index c609ff03ec9..89edbbef92e 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1562,8 +1562,6 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment( SmallVector Record; - PlaceholderQueue Placeholders; - while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); @@ -1572,7 +1570,6 @@ 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,10 +1605,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment( auto Idx = Record[i + 1]; if (Idx < (MDStringRef.size() + GlobalMetadataBitPosIndex.size()) && - !MetadataList.lookup(Idx)) + !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); + } Metadata *Node = MetadataList.getMetadataFwdRef(Idx); if (isa(Node)) -- cgit v1.2.3