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
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
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=internalize %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
15 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
16 target triple = "x86_64-apple-macosx10.11.0"
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
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
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()
33 define linkonce_odr void @linkonceodrfuncwithalias() #0 {
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()
43 define linkonce void @linkoncefuncwithalias() #0 {
48 ; MOD1: define weak_odr void @linkonceodrfunc()
49 ; MOD2: define available_externally void @linkonceodrfunc()
50 define linkonce_odr void @linkonceodrfunc() #0 {
54 ; MOD1: define weak void @linkoncefunc()
55 ; MOD1-INT: define weak void @linkoncefunc()
56 ; MOD2: declare void @linkoncefunc()
57 define linkonce void @linkoncefunc() #0 {
61 ; MOD1: define weak_odr void @weakodrfunc()
62 ; MOD2: define available_externally void @weakodrfunc()
63 define weak_odr void @weakodrfunc() #0 {
67 ; MOD1: define weak void @weakfunc()
68 ; MOD2: declare void @weakfunc()
69 define weak void @weakfunc() #0 {
74 ; MOD1: define weak_odr void @linkonceodrfuncInSingleModule()
75 ; MOD1-INT: define internal void @linkonceodrfuncInSingleModule()
76 ; EXPORTED: define weak_odr void @linkonceodrfuncInSingleModule()
77 define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {