mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-22 18:35:45 +00:00
[ThinLTO] Resolve LinkOnceAny
Summary: Ensure we keep prevailing copy of LinkOnceAny by converting it to WeakAny. Rename odr_resolution test to the now more appropriate weak_resolution (weak in the linker sense includes linkonce). Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D20634 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270850 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
65074d6f38
commit
c7ac92fe36
@ -60,23 +60,14 @@ static void thinLTOResolveWeakForLinkerGUID(
|
||||
// but turned into a weak, while the others will drop it when possible.
|
||||
if (!HasMultipleCopies) {
|
||||
// Exported Linkonce needs to be promoted to not be discarded.
|
||||
// FIXME: This should handle LinkOnceAny as well, but that should be a
|
||||
// follow-on to the NFC restructuring:
|
||||
// if (GlobalValue::isLinkOnceLinkage(OriginalLinkage) &&
|
||||
// isExported(S->modulePath(), GUID))
|
||||
// S->setLinkage(GlobalValue::getWeakLinkage(
|
||||
// GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
|
||||
if (GlobalValue::isLinkOnceODRLinkage(OriginalLinkage) &&
|
||||
if (GlobalValue::isLinkOnceLinkage(OriginalLinkage) &&
|
||||
isExported(S->modulePath(), GUID))
|
||||
S->setLinkage(GlobalValue::WeakODRLinkage);
|
||||
S->setLinkage(GlobalValue::getWeakLinkage(
|
||||
GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
|
||||
} else if (isPrevailing(GUID, S.get())) {
|
||||
// FIXME: This should handle LinkOnceAny as well, but that should be a
|
||||
// follow-on to the NFC restructuring:
|
||||
// if (GlobalValue::isLinkOnceLinkage(OriginalLinkage))
|
||||
// S->setLinkage(GlobalValue::getWeakLinkage(
|
||||
// GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
|
||||
if (GlobalValue::isLinkOnceODRLinkage(OriginalLinkage))
|
||||
S->setLinkage(GlobalValue::WeakODRLinkage);
|
||||
if (GlobalValue::isLinkOnceLinkage(OriginalLinkage))
|
||||
S->setLinkage(GlobalValue::getWeakLinkage(
|
||||
GlobalValue::isLinkOnceODRLinkage(OriginalLinkage)));
|
||||
}
|
||||
// Alias can't be turned into available_externally.
|
||||
else if (!isa<AliasSummary>(S.get()) &&
|
||||
|
@ -2,7 +2,10 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.11.0"
|
||||
|
||||
; Alias are not optimized
|
||||
@linkoncealias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
|
||||
; Alias are not optimized
|
||||
@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
|
||||
|
||||
; Function with an alias are not optimized
|
||||
define linkonce_odr void @linkonceodrfuncwithalias() #0 {
|
||||
@ -10,6 +13,12 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function with an alias are not optimized
|
||||
define linkonce void @linkoncefuncwithalias() #0 {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce_odr void @linkonceodrfunc() #0 {
|
||||
entry:
|
||||
ret void
|
@ -8,7 +8,8 @@
|
||||
|
||||
; NOTPROMOTED: @linkonceODRfuncAlias = alias void (...), bitcast (void ()* @linkonceODRfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @linkonceODRfuncWeakAlias = weak alias void (...), bitcast (void ()* @linkonceODRfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @linkonceODRfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @linkonceODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @linkonceODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkonceODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD2: @linkonceODRfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @linkonceODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @linkonceODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc.mod1 to void (...)*)
|
||||
; PROMOTE_MOD2: @linkonceODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*)
|
||||
; PROMOTE_MOD1: @linkonceODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc.mod1 to void (...)*)
|
||||
@ -16,7 +17,8 @@
|
||||
|
||||
; NOTPROMOTED: @weakODRfuncAlias = alias void (...), bitcast (void ()* @weakODRfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @weakODRfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakODRfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @weakODRfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @weakODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @weakODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD2: @weakODRfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @weakODRfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @weakODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc.mod1 to void (...)*)
|
||||
; PROMOTE_MOD2: @weakODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc to void (...)*)
|
||||
; PROMOTE_MOD1: @weakODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc.mod1 to void (...)*)
|
||||
@ -24,7 +26,8 @@
|
||||
|
||||
; NOTPROMOTED: @linkoncefuncAlias = alias void (...), bitcast (void ()* @linkoncefunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @linkoncefuncWeakAlias = weak alias void (...), bitcast (void ()* @linkoncefunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @linkoncefuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @linkoncefunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @linkoncefuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkoncefunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD2: @linkoncefuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @linkoncefunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @linkoncefuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc.mod1 to void (...)*)
|
||||
; PROMOTE_MOD2: @linkoncefuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc to void (...)*)
|
||||
; PROMOTE_MOD1: @linkoncefuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc.mod1 to void (...)*)
|
||||
@ -32,7 +35,8 @@
|
||||
|
||||
; NOTPROMOTED: @weakfuncAlias = alias void (...), bitcast (void ()* @weakfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @weakfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakfunc{{.*}} to void (...)*)
|
||||
; NOTPROMOTED: @weakfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @weakfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD1: @weakfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakfunc{{.*}} to void (...)*)
|
||||
; PROMOTE_MOD2: @weakfuncLinkonceAlias = linkonce alias void (...), bitcast (void ()* @weakfunc{{.*}} to void (...)*)
|
||||
; FIXME: The "resolution" should turn one of these to linkonce_odr
|
||||
; PROMOTE_MOD1: @weakfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc.mod1 to void (...)*)
|
||||
; PROMOTE_MOD2: @weakfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc to void (...)*)
|
||||
|
@ -1,9 +1,11 @@
|
||||
; Do setup work for all below tests: generate bitcode and combined index
|
||||
; RUN: opt -module-summary %s -o %t.bc
|
||||
; RUN: opt -module-summary %p/Inputs/odr_resolution.ll -o %t2.bc
|
||||
; RUN: opt -module-summary %p/Inputs/weak_resolution.ll -o %t2.bc
|
||||
; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
|
||||
|
||||
; Verify that only one ODR is selected across modules, but non ODR are not affected.
|
||||
; Verify that prevailing weak for linker symbol is selected across modules,
|
||||
; non-prevailing ODR are not kept when possible, but non-ODR non-prevailing
|
||||
; are not affected.
|
||||
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1
|
||||
; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD2
|
||||
; When exported, we always preserve a linkonce
|
||||
@ -13,9 +15,14 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.11.0"
|
||||
|
||||
; Alias are resolved, but can't be turned into "available_externally"
|
||||
; MOD1: @linkoncealias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
; MOD2: @linkoncealias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
@linkoncealias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
; MOD1: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
; MOD2: @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
|
||||
|
||||
; Alias are resolved, but can't be turned into "available_externally"
|
||||
; MOD1: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
|
||||
; MOD2: @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
|
||||
@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
|
||||
|
||||
; Function with an alias are not optimized
|
||||
; MOD1: define linkonce_odr void @linkonceodrfuncwithalias()
|
||||
@ -25,13 +32,21 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function with an alias are not optimized
|
||||
; MOD1: define linkonce void @linkoncefuncwithalias()
|
||||
; MOD2: define linkonce void @linkoncefuncwithalias()
|
||||
define linkonce void @linkoncefuncwithalias() #0 {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; MOD1: define weak_odr void @linkonceodrfunc()
|
||||
; MOD2: define available_externally void @linkonceodrfunc()
|
||||
define linkonce_odr void @linkonceodrfunc() #0 {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
; MOD1: define linkonce void @linkoncefunc()
|
||||
; MOD1: define weak void @linkoncefunc()
|
||||
; MOD2: define linkonce void @linkoncefunc()
|
||||
define linkonce void @linkoncefunc() #0 {
|
||||
entry:
|
Loading…
x
Reference in New Issue
Block a user