mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-08 04:52:50 +00:00
28925b5350
We currently do not touch a symbol's linkage in the case where a definition has a single copy. However, this code is effectively unnecessary: either the definition is not exported, in which case the internalize phase sets its linkage to internal, or it is exported, in which case we need to promote linkage to weak. Those two cases are already handled by existing code. I believe that the only real functional change here is in the case where we have a single definition which does not prevail (e.g. because the definition in a native object file prevails). In that case we now lower linkage to available_externally following the existing code path for that case. As a result we can remove the isExported function parameter from the thinLTOResolveWeakForLinkerInIndex function. Differential Revision: http://reviews.llvm.org/D21883 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274784 91177308-0d34-0410-b5e6-96231b3b80d8
77 lines
3.2 KiB
LLVM
77 lines
3.2 KiB
LLVM
; 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/weak_resolution.ll -o %t2.bc
|
|
; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
|
|
|
|
; 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 %t.bc -thinlto-index=%t3.bc -exported-symbol=linkoncefunc -o - | llvm-lto -thinlto-action=internalize -thinlto-module-id=%t.bc - -thinlto-index=%t3.bc -exported-symbol=linkoncefunc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1-INT
|
|
; 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
|
|
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - --exported-symbol=linkonceodrfuncInSingleModule | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTED
|
|
|
|
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: @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()
|
|
; MOD2: define linkonce_odr void @linkonceodrfuncwithalias()
|
|
define linkonce_odr void @linkonceodrfuncwithalias() #0 {
|
|
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 weak void @linkoncefunc()
|
|
; MOD1-INT: define weak void @linkoncefunc()
|
|
; MOD2: define linkonce void @linkoncefunc()
|
|
define linkonce void @linkoncefunc() #0 {
|
|
entry:
|
|
ret void
|
|
}
|
|
; MOD1: define weak_odr void @weakodrfunc()
|
|
; MOD2: define available_externally void @weakodrfunc()
|
|
define weak_odr void @weakodrfunc() #0 {
|
|
entry:
|
|
ret void
|
|
}
|
|
; MOD1: define weak void @weakfunc()
|
|
; MOD2: define weak void @weakfunc()
|
|
define weak void @weakfunc() #0 {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
; MOD1: define weak_odr void @linkonceodrfuncInSingleModule()
|
|
; MOD1-INT: define internal void @linkonceodrfuncInSingleModule()
|
|
; EXPORTED: define weak_odr void @linkonceodrfuncInSingleModule()
|
|
define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {
|
|
entry:
|
|
ret void
|
|
}
|