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%shlibext \ 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; 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 20; OPT2: target triple = 21; OPT2-NOT: @ 22 23; RUN: llvm-dis %t.o.3.import.bc -o - | FileCheck --check-prefix=IMPORT %s 24; RUN: llvm-dis %t2.o.3.import.bc -o - | FileCheck --check-prefix=IMPORT2 %s 25 26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 27target triple = "x86_64-unknown-linux-gnu" 28 29 30define i32 @main() #0 { 31entry: 32 call void @linkonceodralias() 33 call void @linkoncealias() 34 call void @linkonceodrfuncwithalias() 35 call void @linkoncefuncwithalias() 36 call void @linkonceodrfunc() 37 call void @linkoncefunc() 38 call void @weakodrfunc() 39 call void @weakfunc() 40 call void @linkonceodrfuncInSingleModule() 41 ret i32 0 42} 43 44; Alias are resolved to weak_odr in prevailing module, but left as linkonce_odr 45; in non-prevailing module (illegal to have an available_externally alias). 46; IMPORT: @linkonceodralias = weak_odr alias void (), ptr @linkonceodrfuncwithalias 47; IMPORT2: @linkonceodralias = linkonce_odr alias void (), ptr @linkonceodrfuncwithalias 48@linkonceodralias = linkonce_odr alias void (), ptr @linkonceodrfuncwithalias 49 50; Alias are resolved in prevailing module, but not optimized in 51; non-prevailing module (illegal to have an available_externally alias). 52; IMPORT: @linkoncealias = weak alias void (), ptr @linkoncefuncwithalias 53; IMPORT2: @linkoncealias = linkonce alias void (), ptr @linkoncefuncwithalias 54@linkoncealias = linkonce alias void (), ptr @linkoncefuncwithalias 55 56; Function with an alias are resolved in prevailing module, but 57; not optimized in non-prevailing module (illegal to have an 58; available_externally aliasee). 59; IMPORT: define weak_odr void @linkonceodrfuncwithalias() 60; IMPORT2: define linkonce_odr void @linkonceodrfuncwithalias() 61define linkonce_odr void @linkonceodrfuncwithalias() #0 { 62entry: 63 ret void 64} 65 66; Function with an alias are resolved to weak in prevailing module, but 67; not optimized in non-prevailing module (illegal to have an 68; available_externally aliasee). 69; IMPORT: define weak void @linkoncefuncwithalias() 70; IMPORT2: define linkonce void @linkoncefuncwithalias() 71define linkonce void @linkoncefuncwithalias() #0 { 72entry: 73 ret void 74} 75 76; IMPORT: define weak_odr void @linkonceodrfunc() 77; IMPORT2: define available_externally void @linkonceodrfunc() 78define linkonce_odr void @linkonceodrfunc() #0 { 79entry: 80 ret void 81} 82; IMPORT: define weak void @linkoncefunc() 83; IMPORT2: declare void @linkoncefunc() 84define linkonce void @linkoncefunc() #0 { 85entry: 86 ret void 87} 88; IMPORT: define weak_odr void @weakodrfunc() 89; IMPORT2: define available_externally void @weakodrfunc() 90define weak_odr void @weakodrfunc() #0 { 91entry: 92 ret void 93} 94; IMPORT: define weak void @weakfunc() 95; IMPORT2: declare void @weakfunc() 96define weak void @weakfunc() #0 { 97entry: 98 ret void 99} 100 101; IMPORT: weak_odr void @linkonceodrfuncInSingleModule() 102define linkonce_odr void @linkonceodrfuncInSingleModule() #0 { 103entry: 104 ret void 105} 106