[PATCH] D28751: [ThinLTO] Add a recursive step in Metadata lazy-loading
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 10:47:24 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292420: [ThinLTO] Add a recursive step in Metadata lazy-loading (authored by mehdi_amini).
Changed prior to commit:
https://reviews.llvm.org/D28751?vs=84508&id=84860#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28751
Files:
llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll
Index: llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll
===================================================================
--- llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll
+++ llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll
@@ -17,7 +17,7 @@
; RUN: -o /dev/null -disable-ondemand-mds-loading -stats \
; RUN: 2>&1 | FileCheck %s -check-prefix=NOTLAZY
; NOTLAZY: 58 bitcode-reader - Number of Metadata records loaded
-; NOTLAZY: 8 bitcode-reader - Number of MDStrings loaded
+; NOTLAZY: 6 bitcode-reader - Number of MDStrings loaded
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
@@ -48,7 +48,7 @@
!3 = !{!"3"}
!4 = !{!"4"}
!5 = !{!"5"}
-!6 = !{!"6"}
+!6 = !{!9}
!7 = !{!"7"}
!8 = !{!"8"}
-!9 = !{!"9"}
+!9 = !{!6}
Index: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
===================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -768,13 +768,12 @@
unsigned ID, PlaceholderQueue &Placeholders) {
assert(ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size());
assert(ID >= MDStringRef.size() && "Unexpected lazy-loading of MDString");
-#ifndef NDEBUG
// Lookup first if the metadata hasn't already been loaded.
if (auto *MD = MetadataList.lookup(ID)) {
auto *N = dyn_cast_or_null<MDNode>(MD);
- assert(N && N->isTemporary() && "Lazy loading an already loaded metadata");
+ if (!N->isTemporary())
+ return;
}
-#endif
SmallVector<uint64_t, 64> Record;
StringRef Blob;
IndexCursor.JumpToBit(GlobalMetadataBitPosIndex[ID - MDStringRef.size()]);
@@ -827,8 +826,22 @@
auto getMD = [&](unsigned ID) -> Metadata * {
if (ID < MDStringRef.size())
return lazyLoadOneMDString(ID);
- if (!IsDistinct)
+ if (!IsDistinct) {
+ if (auto *MD = MetadataList.lookup(ID))
+ return MD;
+ // If lazy-loading is enabled, we try recursively to load the operand
+ // instead of creating a temporary.
+ if (ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
+ // Create a temporary for the node that is referencing the operand we
+ // will lazy-load. It is needed before recursing in case there are
+ // uniquing cycles.
+ MetadataList.getMetadataFwdRef(NextMetadataNo);
+ lazyLoadOneMetadata(ID, Placeholders);
+ return MetadataList.lookup(ID);
+ }
+ // Return a temporary.
return MetadataList.getMetadataFwdRef(ID);
+ }
if (auto *MD = MetadataList.getMetadataIfResolved(ID))
return MD;
return &Placeholders.getPlaceholderOp(ID);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28751.84860.patch
Type: text/x-patch
Size: 2656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170118/e53e9d2d/attachment.bin>
More information about the llvm-commits
mailing list