summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-10-30 05:15:23 +0000
committerTeresa Johnson <tejohnson@google.com>2016-10-30 05:15:23 +0000
commit3bc8abdffc648cf1ff17edfed6fcb155b52e823f (patch)
treed1129315532cd132936f387b3c87d645e40c8ea3 /llvm/lib
parent720033ad19fef80d033fc5be806e0f4c62cc0423 (diff)
downloadbcm5719-llvm-3bc8abdffc648cf1ff17edfed6fcb155b52e823f.tar.gz
bcm5719-llvm-3bc8abdffc648cf1ff17edfed6fcb155b52e823f.zip
[ThinLTO] Correctly resolve linkonce when importing aliasee
Summary: When we have an aliasee that is linkonce, while we can't convert the non-prevailing copies to available_externally, we still need to convert the prevailing copy to weak. If a reference to the aliasee is exported, not converting a copy to weak will result in undefined references when the linkonce is removed in its original module. Add a new test and update existing tests. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26076 llvm-svn: 285512
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTO.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index bfb8a5c76a2..654b86a0dfd 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -128,20 +128,25 @@ static void thinLTOResolveWeakForLinkerGUID(
function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
recordNewLinkage) {
for (auto &S : GVSummaryList) {
- if (GlobalInvolvedWithAlias.count(S.get()))
- continue;
GlobalValue::LinkageTypes OriginalLinkage = S->linkage();
if (!GlobalValue::isWeakForLinker(OriginalLinkage))
continue;
// We need to emit only one of these. The prevailing module will keep it,
// but turned into a weak, while the others will drop it when possible.
+ // This is both a compile-time optimization and a correctness
+ // transformation. This is necessary for correctness when we have exported
+ // a reference - we need to convert the linkonce to weak to
+ // ensure a copy is kept to satisfy the exported reference.
+ // FIXME: We may want to split the compile time and correctness
+ // aspects into separate routines.
if (isPrevailing(GUID, S.get())) {
if (GlobalValue::isLinkOnceLinkage(OriginalLinkage))
S->setLinkage(GlobalValue::getWeakLinkage(
GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
}
- // Alias can't be turned into available_externally.
+ // Alias and aliasee can't be turned into available_externally.
else if (!isa<AliasSummary>(S.get()) &&
+ !GlobalInvolvedWithAlias.count(S.get()) &&
(GlobalValue::isLinkOnceODRLinkage(OriginalLinkage) ||
GlobalValue::isWeakODRLinkage(OriginalLinkage)))
S->setLinkage(GlobalValue::AvailableExternallyLinkage);
OpenPOWER on IntegriCloud