• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -module-summary %s -o %t.o
2; RUN: opt -module-summary %p/Inputs/thinlto_weak_resolution.ll -o %t2.o
3
4; Verify that prevailing weak for linker symbol is kept.
5; Note that gold picks the first copy of a function as the prevailing one,
6; so listing %t.o first is sufficient to ensure that its copies are prevailing.
7; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \
8; RUN:     --plugin-opt=thinlto \
9; RUN:     --plugin-opt=save-temps \
10; RUN:     -shared \
11; RUN:     -o %t3.o %t.o %t2.o
12
13; RUN: llvm-nm %t3.o | FileCheck %s
14; CHECK: weakfunc
15
16; All of the preempted functions should have been eliminated (the plugin will
17; not link them in).
18; RUN: llvm-dis %t2.o.opt.bc -o - | FileCheck --check-prefix=OPT2 %s
19; OPT2-NOT: @
20
21; RUN: llvm-dis %t.o.opt.bc -o - | FileCheck --check-prefix=OPT %s
22
23target triple = "x86_64-unknown-linux-gnu"
24
25
26define i32 @main() #0 {
27entry:
28  call void @linkonceodralias()
29  call void @linkoncealias()
30  call void @linkonceodrfuncwithalias()
31  call void @linkoncefuncwithalias()
32  call void @linkonceodrfunc()
33  call void @linkoncefunc()
34  call void @weakodrfunc()
35  call void @weakfunc()
36  call void @linkonceodrfuncInSingleModule()
37  ret i32 0
38}
39
40; Alias are resolved
41; OPT: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
42@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
43
44; Alias are resolved
45; OPT: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
46@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
47
48; Function with an alias are not optimized
49; OPT: define linkonce_odr void @linkonceodrfuncwithalias()
50define linkonce_odr void @linkonceodrfuncwithalias() #0 {
51entry:
52  ret void
53}
54
55; Function with an alias are not optimized
56; OPT: define linkonce void @linkoncefuncwithalias()
57define linkonce void @linkoncefuncwithalias() #0 {
58entry:
59  ret void
60}
61
62; OPT: define weak_odr void @linkonceodrfunc()
63define linkonce_odr void @linkonceodrfunc() #0 {
64entry:
65  ret void
66}
67; OPT: define weak void @linkoncefunc()
68define linkonce void @linkoncefunc() #0 {
69entry:
70  ret void
71}
72; OPT: define weak_odr void @weakodrfunc()
73define weak_odr void @weakodrfunc() #0 {
74entry:
75  ret void
76}
77; OPT: define weak void @weakfunc()
78define weak void @weakfunc() #0 {
79entry:
80  ret void
81}
82
83; OPT: weak_odr void @linkonceodrfuncInSingleModule()
84define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {
85entry:
86  ret void
87}
88