Restore "Move metadata linking after lazy global materialization/linking."
[oota-llvm.git] / lib / Linker / LinkModules.cpp
index 4a12633c3055fcb76de1a8ffc51c1a417fe9cc79..74ca197ddb3cf38bad3466a7b5bedb7afbf18630 100644 (file)
@@ -1892,15 +1892,6 @@ bool ModuleLinker::run() {
     linkGlobalValueBody(Src);
   }
 
-  // Remap all of the named MDNodes in Src into the DstM module. We do this
-  // after linking GlobalValues so that MDNodes that reference GlobalValues
-  // are properly remapped.
-  linkNamedMDNodes();
-
-  // Merge the module flags into the DstM module.
-  if (linkModuleFlagsMetadata())
-    return true;
-
   // Update the initializers in the DstM module now that all globals that may
   // be referenced are in DstM.
   for (GlobalVariable &Src : SrcM->globals()) {
@@ -1927,6 +1918,15 @@ bool ModuleLinker::run() {
       return true;
   }
 
+  // Remap all of the named MDNodes in Src into the DstM module. We do this
+  // after linking GlobalValues so that MDNodes that reference GlobalValues
+  // are properly remapped.
+  linkNamedMDNodes();
+
+  // Merge the module flags into the DstM module.
+  if (linkModuleFlagsMetadata())
+    return true;
+
   return false;
 }