xref: /llvm-project/llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll (revision 20faf789199d31a40c7f1a359361980c65067aab)
1; RUN: split-file %s %t
2; RUN: opt -thinlto-bc %t/a.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
3; RUN: opt -thinlto-bc %t/b.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t2.bc
4; RUN: opt -thinlto-bc %t/c.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t3.bc
5
6; If the prevailing weak symbol is defined in a native file, the IR copies should be dead and propagation should not occur
7; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc %t3.bc -o %t.o \
8; RUN:               -r %t1.bc,caller,px -r %t1.bc,callee,lx \
9; RUN:               -r %t2.bc,callee,x \
10; RUN:               -r %t3.bc,callee,x \
11; RUN:               -save-temps
12
13; RUN: llvm-dis -o - %t.o.1.3.import.bc | FileCheck %s
14
15; If the prevailing weak symbol is in an IR file, it should be the one used in the final binary and thus propagation
16; should be based off of that copy
17; RUN: llvm-lto2 run -O3 -disable-thinlto-funcattrs=0 %t1.bc %t2.bc %t3.bc -o %t.2.o \
18; RUN:               -r %t1.bc,caller,px -r %t1.bc,callee,lx \
19; RUN:               -r %t2.bc,callee,px \
20; RUN:               -r %t3.bc,callee,x \
21; RUN:               -save-temps
22
23; RUN: llvm-dis -o - %t.2.o.1.3.import.bc | FileCheck %s --check-prefix=PREVAILING
24; RUN: llvm-dis -o - %t.2.o.2.3.import.bc | FileCheck %s --check-prefix=PREVAILING-B
25; RUN: llvm-dis -o - %t.2.o.3.3.import.bc | FileCheck %s --check-prefix=PREVAILING-C
26
27;--- a.ll
28target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
29target triple = "x86_64-unknown-linux-gnu"
30
31declare i32 @callee()
32
33; CHECK-NOT: Function Attrs:
34; CHECK: define i32 @caller()
35
36; PREVAILING: Function Attrs: norecurse nounwind
37; PREVAILING-NEXT: define i32 @caller()
38define i32 @caller() {
39  %res = call i32 @callee()
40  ret i32 %res
41}
42
43;--- b.ll
44target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45target triple = "x86_64-unknown-linux-gnu"
46
47; PREVAILING-B: define weak i32 @callee()
48define weak i32 @callee() {
49  ret i32 5
50}
51
52;--- c.ll
53target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
54target triple = "x86_64-unknown-linux-gnu"
55
56; PREVAILING-C: declare i32 @callee()
57define weak i32 @callee() {
58  ret i32 6
59}
60
61