Move metadata linking after lazy global materialization/linking.
authorTeresa Johnson <tejohnson@google.com>
Tue, 3 Nov 2015 15:11:27 +0000 (15:11 +0000)
committerTeresa Johnson <tejohnson@google.com>
Tue, 3 Nov 2015 15:11:27 +0000 (15:11 +0000)
commit20f7585a5c52c5ecbff7baff0959f4ed4cbd711b
tree4bcac99bdb35dcac0bba5cf067bb5d77dbfbd53d
parentfb792d346f2eb65d2e0b3065b0f2e6310aa47223
Move metadata linking after lazy global materialization/linking.

Summary:
Currently, named metadata is linked before the LazilyLinkGlobalValues
list is walked and materialized/linked. As a result, references
from DISubprogram and DIGlobalVariable metadata to yet unmaterialized
functions and variables cause them to be added to the lazy linking
list and their definitions are materialized and linked.

This makes the llvm-link -only-needed option not have the intended
effect when debug information is present, as the otherwise unneeded
functions/variables are still linked in.

Additionally, for ThinLTO I have implemented a mechanism to only link
in debug metadata needed by imported functions. Moving named metadata
linking after lazy GV linking will facilitate applying this mechanism
to the LTO and "llvm-link -only-needed" cases as well.

Reviewers: dexonsmith, tra, dblaikie

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14195

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251926 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Linker/LinkModules.cpp
test/Linker/Inputs/only-needed-named-metadata.ll [new file with mode: 0644]
test/Linker/only-needed-named-metadata.ll [new file with mode: 0644]