[PATCH] D17992: Materialize metadata in IRLinker before value mapping

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 07:30:00 PST 2016


tejohnson created this revision.
tejohnson added a reviewer: rafael.
tejohnson added subscribers: llvm-commits, silvas.

Unless we plan to do later postpass metadata linking (ThinLTO special mode),
always invoke metadata materialization at the start of IRLinker::run().
This avoids the need for clients who use lazy metadata loading to
explicitly invoke materializeMetadata before the IRMover, which in
turn invokes IRLinker::run and needs materialized metadata for mapping.

Came up in the context of an LLD issue (D17982).

http://reviews.llvm.org/D17992

Files:
  lib/Linker/IRMover.cpp

Index: lib/Linker/IRMover.cpp
===================================================================
--- lib/Linker/IRMover.cpp
+++ lib/Linker/IRMover.cpp
@@ -1492,6 +1492,11 @@
 }
 
 bool IRLinker::run() {
+  // Ensure metadata materialized before value mapping.
+  if (shouldLinkMetadata() && SrcM->getMaterializer())
+    if (SrcM->getMaterializer()->materializeMetadata())
+      return true;
+
   // Inherit the target data from the source module if the destination module
   // doesn't have one already.
   if (DstM.getDataLayout().isDefault())
@@ -1559,13 +1564,9 @@
     // Even if just linking metadata we should link decls above in case
     // any are referenced by metadata. IRLinker::shouldLink ensures that
     // we don't actually link anything from source.
-    if (IsMetadataLinkingPostpass) {
-      // Ensure metadata materialized
-      if (SrcM->getMaterializer()->materializeMetadata())
-        return true;
+    if (IsMetadataLinkingPostpass)
       SrcM->getMaterializer()->saveMetadataList(MetadataToIDs,
                                                 /* OnlyTempMD = */ false);
-    }
 
     linkNamedMDNodes();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17992.50135.patch
Type: text/x-patch
Size: 1141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160309/7cf9bc13/attachment.bin>


More information about the llvm-commits mailing list