xref: /aosp_15_r20/external/llvm/test/ThinLTO/X86/weak_resolution.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Do setup work for all below tests: generate bitcode and combined index
2*9880d681SAndroid Build Coastguard Worker; RUN: opt -module-summary %s -o %t.bc
3*9880d681SAndroid Build Coastguard Worker; RUN: opt -module-summary %p/Inputs/weak_resolution.ll -o %t2.bc
4*9880d681SAndroid Build Coastguard Worker; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Verify that prevailing weak for linker symbol is selected across modules,
7*9880d681SAndroid Build Coastguard Worker; non-prevailing ODR are not kept when possible, but non-ODR non-prevailing
8*9880d681SAndroid Build Coastguard Worker; are not affected.
9*9880d681SAndroid Build Coastguard Worker; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1
10*9880d681SAndroid Build Coastguard Worker; 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
11*9880d681SAndroid Build Coastguard Worker; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD2
12*9880d681SAndroid Build Coastguard Worker; When exported, we always preserve a linkonce
13*9880d681SAndroid Build Coastguard Worker; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - --exported-symbol=linkonceodrfuncInSingleModule | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTED
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
16*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.11.0"
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; Alias are resolved, but can't be turned into "available_externally"
19*9880d681SAndroid Build Coastguard Worker; MOD1: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
20*9880d681SAndroid Build Coastguard Worker; MOD2: @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
21*9880d681SAndroid Build Coastguard Worker@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker; Alias are resolved, but can't be turned into "available_externally"
24*9880d681SAndroid Build Coastguard Worker; MOD1: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
25*9880d681SAndroid Build Coastguard Worker; MOD2: @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
26*9880d681SAndroid Build Coastguard Worker@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Function with an alias are not optimized
29*9880d681SAndroid Build Coastguard Worker; MOD1: define linkonce_odr void @linkonceodrfuncwithalias()
30*9880d681SAndroid Build Coastguard Worker; MOD2: define linkonce_odr void @linkonceodrfuncwithalias()
31*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @linkonceodrfuncwithalias() #0 {
32*9880d681SAndroid Build Coastguard Workerentry:
33*9880d681SAndroid Build Coastguard Worker  ret void
34*9880d681SAndroid Build Coastguard Worker}
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker; Function with an alias are not optimized
37*9880d681SAndroid Build Coastguard Worker; MOD1: define linkonce void @linkoncefuncwithalias()
38*9880d681SAndroid Build Coastguard Worker; MOD2: define linkonce void @linkoncefuncwithalias()
39*9880d681SAndroid Build Coastguard Workerdefine linkonce void @linkoncefuncwithalias() #0 {
40*9880d681SAndroid Build Coastguard Workerentry:
41*9880d681SAndroid Build Coastguard Worker  ret void
42*9880d681SAndroid Build Coastguard Worker}
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker; MOD1: define weak_odr void @linkonceodrfunc()
45*9880d681SAndroid Build Coastguard Worker; MOD2: define available_externally void @linkonceodrfunc()
46*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @linkonceodrfunc() #0 {
47*9880d681SAndroid Build Coastguard Workerentry:
48*9880d681SAndroid Build Coastguard Worker  ret void
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker; MOD1: define weak void @linkoncefunc()
51*9880d681SAndroid Build Coastguard Worker; MOD1-INT: define weak void @linkoncefunc()
52*9880d681SAndroid Build Coastguard Worker; MOD2: define linkonce void @linkoncefunc()
53*9880d681SAndroid Build Coastguard Workerdefine linkonce void @linkoncefunc() #0 {
54*9880d681SAndroid Build Coastguard Workerentry:
55*9880d681SAndroid Build Coastguard Worker  ret void
56*9880d681SAndroid Build Coastguard Worker}
57*9880d681SAndroid Build Coastguard Worker; MOD1: define weak_odr void @weakodrfunc()
58*9880d681SAndroid Build Coastguard Worker; MOD2: define available_externally void @weakodrfunc()
59*9880d681SAndroid Build Coastguard Workerdefine weak_odr void @weakodrfunc() #0 {
60*9880d681SAndroid Build Coastguard Workerentry:
61*9880d681SAndroid Build Coastguard Worker  ret void
62*9880d681SAndroid Build Coastguard Worker}
63*9880d681SAndroid Build Coastguard Worker; MOD1: define weak void @weakfunc()
64*9880d681SAndroid Build Coastguard Worker; MOD2: define weak void @weakfunc()
65*9880d681SAndroid Build Coastguard Workerdefine weak void @weakfunc() #0 {
66*9880d681SAndroid Build Coastguard Workerentry:
67*9880d681SAndroid Build Coastguard Worker  ret void
68*9880d681SAndroid Build Coastguard Worker}
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker; MOD1: define weak_odr void @linkonceodrfuncInSingleModule()
71*9880d681SAndroid Build Coastguard Worker; MOD1-INT: define internal void @linkonceodrfuncInSingleModule()
72*9880d681SAndroid Build Coastguard Worker; EXPORTED: define weak_odr void @linkonceodrfuncInSingleModule()
73*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @linkonceodrfuncInSingleModule() #0 {
74*9880d681SAndroid Build Coastguard Workerentry:
75*9880d681SAndroid Build Coastguard Worker  ret void
76*9880d681SAndroid Build Coastguard Worker}
77