1 ; RUN: split-file %s %t
2 ; RUN: opt -module-summary %t/a.ll -o %t/a.bc
3 ; RUN: opt -module-summary %t/b.ll -o %t/b.bc
4 ; RUN: opt -module-summary %t/c.ll -o %t/c.bc
6 ;; ThinLTO Function attribute propagation uses the prevailing symbol to propagate attributes to its callers.
7 ;; Interposable (linkonce and weak) linkages are fair game given we know the prevailing copy will be used in the final binary.
8 ; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t/a.bc %t/b.bc %t/c.bc -o %t1 -save-temps \
9 ; RUN: -r=%t/a.bc,call_extern,plx -r=%t/a.bc,call_linkonceodr,plx -r=%t/a.bc,call_weakodr,plx -r=%t/a.bc,call_linkonce,plx -r=%t/a.bc,call_weak,plx -r=%t/a.bc,call_linkonce_may_unwind,plx -r=%t/a.bc,call_weak_may_unwind,plx \
10 ; RUN: -r=%t/a.bc,extern, -r=%t/a.bc,linkonceodr, -r=%t/a.bc,weakodr, -r=%t/a.bc,linkonce, -r=%t/a.bc,weak, -r=%t/a.bc,linkonce_may_unwind, -r=%t/a.bc,weak_may_unwind, \
11 ; RUN: -r=%t/b.bc,extern,p -r=%t/b.bc,linkonceodr,p -r=%t/b.bc,weakodr,p -r=%t/b.bc,linkonce,p -r=%t/b.bc,weak,p -r=%t/b.bc,linkonce_may_unwind,p -r=%t/b.bc,weak_may_unwind, \
12 ; RUN: -r=%t/c.bc,extern, -r=%t/c.bc,linkonceodr, -r=%t/c.bc,weakodr, -r=%t/c.bc,linkonce, -r=%t/c.bc,weak, -r=%t/c.bc,linkonce_may_unwind, -r=%t/c.bc,weak_may_unwind,p -r=%t/c.bc,may_throw,
14 ; RUN: llvm-dis %t1.1.3.import.bc -o - | FileCheck %s
17 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
18 target triple = "x86_64-unknown-linux-gnu"
20 ;; These functions are identical between b.ll and c.ll
21 declare void @extern()
22 declare void @linkonceodr()
23 declare void @weakodr()
25 declare void @linkonce()
28 ;; b.ll contains non-throwing copies of these functions
29 ;; c.ll contains throwing copies of these functions
30 declare void @linkonce_may_unwind()
31 declare void @weak_may_unwind()
33 ; CHECK: define dso_local void @call_extern() [[ATTR_NOUNWIND:#[0-9]+]]
34 define void @call_extern() {
39 ; CHECK: define dso_local void @call_linkonceodr() [[ATTR_NOUNWIND:#[0-9]+]]
40 define void @call_linkonceodr() {
41 call void @linkonceodr()
45 ; CHECK: define dso_local void @call_weakodr() [[ATTR_NOUNWIND:#[0-9]+]]
46 define void @call_weakodr() {
51 ; CHECK: define dso_local void @call_linkonce() [[ATTR_NOUNWIND:#[0-9]+]]
52 define void @call_linkonce() {
57 ; CHECK: define dso_local void @call_weak() [[ATTR_NOUNWIND:#[0-9]+]]
58 define void @call_weak() {
63 ; CHECK: define dso_local void @call_linkonce_may_unwind() [[ATTR_NOUNWIND:#[0-9]+]]
64 ;; The prevailing copy here comes from b.ll, which contains nounwind and norecurse
65 define void @call_linkonce_may_unwind() {
66 call void @linkonce_may_unwind()
70 ; CHECK: define dso_local void @call_weak_may_unwind() [[ATTR_MAYTHROW:#[0-9]+]]
71 ;; The prevailing copy hree comes from c.ll, which only contains norecurse
72 define void @call_weak_may_unwind() {
73 call void @weak_may_unwind()
77 ; CHECK-DAG: attributes [[ATTR_NOUNWIND]] = { norecurse nounwind }
78 ; CHECK-DAG: attributes [[ATTR_MAYTHROW]] = { norecurse }
81 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
82 target triple = "x86_64-unknown-linux-gnu"
84 attributes #0 = { nounwind norecurse }
86 define void @extern() #0 {
90 define linkonce_odr void @linkonceodr() #0 {
94 define weak_odr void @weakodr() #0 {
98 define linkonce void @linkonce() #0 {
102 define weak void @weak() #0 {
106 define linkonce void @linkonce_may_unwind() #0 {
110 define weak void @weak_may_unwind() #0 {
115 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
116 target triple = "x86_64-unknown-linux-gnu"
118 attributes #0 = { nounwind norecurse }
119 attributes #1 = { norecurse }
121 define void @extern() #0 {
125 define linkonce_odr void @linkonceodr() #0 {
129 define weak_odr void @weakodr() #0 {
133 define linkonce void @linkonce() #0 {
137 define weak void @weak() #0 {
141 declare void @may_throw()
143 define linkonce void @linkonce_may_unwind() #1 {
144 call void @may_throw()
148 define weak void @weak_may_unwind() #1 {
149 call void @may_throw()