diff options
| author | Teresa Johnson <tejohnson@google.com> | 2015-11-06 17:50:48 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2015-11-06 17:50:48 +0000 |
| commit | 189b2526527c02b9ef4234266b51807308d4662a (patch) | |
| tree | b3e980b52b227f213ddc5b7e356ee5dcfeee688b | |
| parent | b8fd162fc569449fcf4e650978865c6437edd739 (diff) | |
| download | bcm5719-llvm-189b2526527c02b9ef4234266b51807308d4662a.tar.gz bcm5719-llvm-189b2526527c02b9ef4234266b51807308d4662a.zip | |
Restore "Move metadata linking after lazy global materialization/linking."
This reverts commit r251965.
llvm-svn: 252319
| -rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 18 | ||||
| -rw-r--r-- | llvm/test/Linker/Inputs/only-needed-named-metadata.ll | 9 | ||||
| -rw-r--r-- | llvm/test/Linker/only-needed-named-metadata.ll | 16 |
3 files changed, 34 insertions, 9 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 4a12633c305..74ca197ddb3 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -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; } diff --git a/llvm/test/Linker/Inputs/only-needed-named-metadata.ll b/llvm/test/Linker/Inputs/only-needed-named-metadata.ll new file mode 100644 index 00000000000..fa7bc2e3cc8 --- /dev/null +++ b/llvm/test/Linker/Inputs/only-needed-named-metadata.ll @@ -0,0 +1,9 @@ +@X = external global i32 + +declare i32 @foo() + +define void @bar() { + load i32, i32* @X + call i32 @foo() + ret void +} diff --git a/llvm/test/Linker/only-needed-named-metadata.ll b/llvm/test/Linker/only-needed-named-metadata.ll new file mode 100644 index 00000000000..f64637d3c75 --- /dev/null +++ b/llvm/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() + +@X = global i32 5 +@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} |

