[llvm-branch-commits] [llvm-branch] r292760 - LLVM 4.0: Merge r292641 "[ThinLTO] Fix lazy-loading of MDString instruction attachments"

Mehdi Amini via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jan 22 11:37:25 PST 2017


Author: mehdi_amini
Date: Sun Jan 22 13:37:24 2017
New Revision: 292760

URL: http://llvm.org/viewvc/llvm-project?rev=292760&view=rev
Log:
LLVM 4.0: Merge r292641 "[ThinLTO] Fix lazy-loading of MDString instruction attachments"


Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp
    llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h
    llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan 22 13:37:24 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667,292711
+/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292641,292667,292711

Modified: llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp?rev=292760&r1=292759&r2=292760&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp Sun Jan 22 13:37:24 2017
@@ -512,7 +512,7 @@ private:
   }
 
   Metadata *getFnMetadataByID(unsigned ID) {
-    return MDLoader->getMetadataFwdRef(ID);
+    return MDLoader->getMetadataFwdRefOrLoad(ID);
   }
 
   BasicBlock *getBasicBlock(unsigned ID) const {

Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp?rev=292760&r1=292759&r2=292760&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp Sun Jan 22 13:37:24 2017
@@ -485,8 +485,21 @@ public:
   Error parseMetadata(bool ModuleLevel);
 
   bool hasFwdRefs() const { return MetadataList.hasFwdRefs(); }
-  Metadata *getMetadataFwdRef(unsigned Idx) {
-    return MetadataList.getMetadataFwdRef(Idx);
+
+  Metadata *getMetadataFwdRefOrLoad(unsigned ID) {
+    if (ID < MDStringRef.size())
+      return lazyLoadOneMDString(ID);
+    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())) {
+      PlaceholderQueue Placeholders;
+      lazyLoadOneMetadata(ID, Placeholders);
+      resolveForwardRefsAndPlaceholders(Placeholders);
+      return MetadataList.lookup(ID);
+    }
+    return MetadataList.getMetadataFwdRef(ID);
   }
 
   MDNode *getMDNodeFwdRefOrNull(unsigned Idx) {
@@ -1727,8 +1740,8 @@ bool MetadataLoader::hasFwdRefs() const
 
 /// Return the given metadata, creating a replaceable forward reference if
 /// necessary.
-Metadata *MetadataLoader::getMetadataFwdRef(unsigned Idx) {
-  return Pimpl->getMetadataFwdRef(Idx);
+Metadata *MetadataLoader::getMetadataFwdRefOrLoad(unsigned Idx) {
+  return Pimpl->getMetadataFwdRefOrLoad(Idx);
 }
 
 MDNode *MetadataLoader::getMDNodeFwdRefOrNull(unsigned Idx) {

Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h?rev=292760&r1=292759&r2=292760&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h (original)
+++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h Sun Jan 22 13:37:24 2017
@@ -63,7 +63,7 @@ public:
 
   /// Return the given metadata, creating a replaceable forward reference if
   /// necessary.
-  Metadata *getMetadataFwdRef(unsigned Idx);
+  Metadata *getMetadataFwdRefOrLoad(unsigned Idx);
 
   MDNode *getMDNodeFwdRefOrNull(unsigned Idx);
 

Modified: llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll?rev=292760&r1=292759&r2=292760&view=diff
==============================================================================
--- llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll (original)
+++ llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll Sun Jan 22 13:37:24 2017
@@ -11,19 +11,20 @@
 ; RUN:          -o /dev/null -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=LAZY
 ; LAZY: 49 bitcode-reader  - Number of Metadata records loaded
-; LAZY: 1 bitcode-reader  - Number of MDStrings loaded
+; LAZY: 2 bitcode-reader  - Number of MDStrings loaded
 
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; 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: 6 bitcode-reader  - Number of MDStrings loaded
+; NOTLAZY: 7 bitcode-reader  - Number of MDStrings loaded
 
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.11.0"
 
 define void @globalfunc1(i32 %arg) {
+  %x = call i1 @llvm.type.test(i8* undef, metadata !"typeid1")
   %tmp = add i32 %arg, 0, !metadata !2
   ret void
 }
@@ -34,6 +35,7 @@ define void @globalfunc1(i32 %arg) {
 ; These function are not imported and so we don't want to load their metadata.
 
 define void @globalfunc2(i32 %arg) {
+  %x = call i1 @llvm.type.test(i8* undef, metadata !"typeid1")
   %tmp = add i32 %arg, 0, !metadata !1
   ret void
 }
@@ -43,6 +45,8 @@ define void @globalfunc3(i32 %arg) {
   ret void
 }
 
+declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
+
 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
 !2 = !{!"Hello World"}
 !3 = !{!"3"}
@@ -51,4 +55,4 @@ define void @globalfunc3(i32 %arg) {
 !6 = !{!9}
 !7 = !{!"7"}
 !8 = !{!"8"}
-!9 = !{!6}
+!9 = !{!6}
\ No newline at end of file




More information about the llvm-branch-commits mailing list