[PATCH] D14195: Move metadata linking after lazy global materialization/linking.

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 07:13:54 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL251926: Move metadata linking after lazy global materialization/linking. (authored by tejohnson).

Changed prior to commit:
  http://reviews.llvm.org/D14195?vs=38784&id=39061#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14195

Files:
  llvm/trunk/lib/Linker/LinkModules.cpp
  llvm/trunk/test/Linker/Inputs/only-needed-named-metadata.ll
  llvm/trunk/test/Linker/only-needed-named-metadata.ll

Index: llvm/trunk/lib/Linker/LinkModules.cpp
===================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp
+++ llvm/trunk/lib/Linker/LinkModules.cpp
@@ -1940,15 +1940,6 @@
     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()) {
@@ -1975,6 +1966,15 @@
       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;
 }
 
Index: llvm/trunk/test/Linker/only-needed-named-metadata.ll
===================================================================
--- llvm/trunk/test/Linker/only-needed-named-metadata.ll
+++ llvm/trunk/test/Linker/only-needed-named-metadata.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-as %S/only-needed-named-metadata.ll -o %t.bc
+; RUN: llvm-as %S/Inputs/only-needed-named-metadata.ll -o %t2.bc
+; RUN: llvm-link -S -only-needed %t2.bc %t.bc | FileCheck %s
+; RUN: llvm-link -S -internalize -only-needed %t2.bc %t.bc | FileCheck %s
+
+; CHECK: @U = external global i32
+; CHECK: declare i32 @unused()
+
+ at X = global i32 5
+ at U = global i32 6
+define i32 @foo() { ret i32 7 }
+define i32 @unused() { ret i32 8 }
+
+!llvm.named = !{!0, !1}
+!0 = !{i32 ()* @unused}
+!1 = !{i32* @U}
Index: llvm/trunk/test/Linker/Inputs/only-needed-named-metadata.ll
===================================================================
--- llvm/trunk/test/Linker/Inputs/only-needed-named-metadata.ll
+++ llvm/trunk/test/Linker/Inputs/only-needed-named-metadata.ll
@@ -0,0 +1,9 @@
+ at X = external global i32
+
+declare i32 @foo()
+
+define void @bar() {
+	load i32, i32* @X
+	call i32 @foo()
+	ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14195.39061.patch
Type: text/x-patch
Size: 2287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151103/9ce89618/attachment.bin>


More information about the llvm-commits mailing list