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 15target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 16target 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 resolved to weak_odr in prevailing module, but 29; not optimized in non-prevailing module (illegal to have an 30; available_externally aliasee). 31; MOD1: define weak_odr void @linkonceodrfuncwithalias() 32; MOD2: define linkonce_odr void @linkonceodrfuncwithalias() 33define linkonce_odr void @linkonceodrfuncwithalias() #0 { 34entry: 35 ret void 36} 37 38; Function with an alias are resolved to weak in prevailing module, but 39; not optimized in non-prevailing module (illegal to have an 40; available_externally aliasee). 41; MOD1: define weak void @linkoncefuncwithalias() 42; MOD2: define linkonce void @linkoncefuncwithalias() 43define linkonce void @linkoncefuncwithalias() #0 { 44entry: 45 ret void 46} 47 48; MOD1: define weak_odr void @linkonceodrfunc() 49; MOD2: define available_externally void @linkonceodrfunc() 50define linkonce_odr void @linkonceodrfunc() #0 { 51entry: 52 ret void 53} 54; MOD1: define weak void @linkoncefunc() 55; MOD1-INT: define weak void @linkoncefunc() 56; MOD2: declare void @linkoncefunc() 57define linkonce void @linkoncefunc() #0 { 58entry: 59 ret void 60} 61; MOD1: define weak_odr void @weakodrfunc() 62; MOD2: define available_externally void @weakodrfunc() 63define weak_odr void @weakodrfunc() #0 { 64entry: 65 ret void 66} 67; MOD1: define weak void @weakfunc() 68; MOD2: declare void @weakfunc() 69define weak void @weakfunc() #0 { 70entry: 71 ret void 72} 73 74; MOD1: define weak_odr void @linkonceodrfuncInSingleModule() 75; MOD1-INT: define internal void @linkonceodrfuncInSingleModule() 76; EXPORTED: define weak_odr void @linkonceodrfuncInSingleModule() 77define linkonce_odr void @linkonceodrfuncInSingleModule() #0 { 78entry: 79 ret void 80} 81