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