1 ; RUN: opt -module-summary %s -o %t.o
2 ; RUN: opt -module-summary %p/Inputs/thinlto_weak_resolution.ll -o %t2.o
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%shlibext \
8 ; RUN: --plugin-opt=thinlto \
9 ; RUN: --plugin-opt=save-temps \
11 ; RUN: -o %t3.o %t.o %t2.o
13 ; RUN: llvm-nm %t3.o | FileCheck %s
16 ; The preempted functions should have been eliminated (the plugin will
17 ; set linkage of odr functions to available_externally, and convert
18 ; linkonce and weak to declarations).
19 ; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck --check-prefix=OPT2 %s
22 ; RUN: llvm-dis %t.o.3.import.bc -o - | FileCheck --check-prefix=IMPORT %s
23 ; RUN: llvm-dis %t2.o.3.import.bc -o - | FileCheck --check-prefix=IMPORT2 %s
25 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-unknown-linux-gnu"
29 define i32 @main() #0 {
31 call void @linkonceodralias()
32 call void @linkoncealias()
33 call void @linkonceodrfuncwithalias()
34 call void @linkoncefuncwithalias()
35 call void @linkonceodrfunc()
36 call void @linkoncefunc()
37 call void @weakodrfunc()
39 call void @linkonceodrfuncInSingleModule()
43 ; Alias are resolved to weak_odr in prevailing module, but left as linkonce_odr
44 ; in non-prevailing module (illegal to have an available_externally alias).
45 ; IMPORT: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
46 ; IMPORT2: @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
47 @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
49 ; Alias are resolved in prevailing module, but not optimized in
50 ; non-prevailing module (illegal to have an available_externally alias).
51 ; IMPORT: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
52 ; IMPORT2: @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
53 @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
55 ; Function with an alias are resolved in prevailing module, but
56 ; not optimized in non-prevailing module (illegal to have an
57 ; available_externally aliasee).
58 ; IMPORT: define weak_odr void @linkonceodrfuncwithalias()
59 ; IMPORT2: define linkonce_odr void @linkonceodrfuncwithalias()
60 define linkonce_odr void @linkonceodrfuncwithalias() #0 {
65 ; Function with an alias are resolved to weak in prevailing module, but
66 ; not optimized in non-prevailing module (illegal to have an
67 ; available_externally aliasee).
68 ; IMPORT: define weak void @linkoncefuncwithalias()
69 ; IMPORT2: define linkonce void @linkoncefuncwithalias()
70 define linkonce void @linkoncefuncwithalias() #0 {
75 ; IMPORT: define weak_odr void @linkonceodrfunc()
76 ; IMPORT2: define available_externally void @linkonceodrfunc()
77 define linkonce_odr void @linkonceodrfunc() #0 {
81 ; IMPORT: define weak void @linkoncefunc()
82 ; IMPORT2: declare void @linkoncefunc()
83 define linkonce void @linkoncefunc() #0 {
87 ; IMPORT: define weak_odr void @weakodrfunc()
88 ; IMPORT2: define available_externally void @weakodrfunc()
89 define weak_odr void @weakodrfunc() #0 {
93 ; IMPORT: define weak void @weakfunc()
94 ; IMPORT2: declare void @weakfunc()
95 define weak void @weakfunc() #0 {
100 ; IMPORT: weak_odr void @linkonceodrfuncInSingleModule()
101 define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {