xref: /llvm-project/llvm/test/ThinLTO/X86/public-type-test.ll (revision a40b0c3e77a28b8dee5af7f9d9cdc9ad5919077e)
1; Test to ensure that the LTO API (legacy and new) lowers @llvm.public.type.test.
2
3; RUN: split-file %s %t
4
5; RUN: opt -module-summary %t/main.ll -o %t/main.bc
6; RUN: opt -module-summary %t/foo.ll -o %t/foo.bc
7; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t/main.bc %t/foo.bc --thinlto-save-temps=%t2.
8; RUN: llvm-dis -o - %t2.0.3.imported.bc | FileCheck %s --check-prefix=PUBLIC
9; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t/main.bc %t/foo.bc --thinlto-save-temps=%t2. --whole-program-visibility
10; RUN: llvm-dis -o - %t2.0.3.imported.bc | FileCheck %s --check-prefix=HIDDEN
11
12; RUN: llvm-lto2 run %t/main.bc %t/foo.bc -save-temps -pass-remarks=. \
13; RUN:   -whole-program-visibility \
14; RUN:   -o %t3 \
15; RUN:   -r=%t/main.bc,_main,px \
16; RUN:   -r=%t/main.bc,_bar,px \
17; RUN:   -r=%t/main.bc,_foo, \
18; RUN:   -r=%t/foo.bc,_foo,px
19; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=HIDDEN
20; RUN: llvm-lto2 run %t/main.bc %t/foo.bc -save-temps -pass-remarks=. \
21; RUN:   -o %t3 \
22; RUN:   -r=%t/main.bc,_main,px \
23; RUN:   -r=%t/main.bc,_bar,px \
24; RUN:   -r=%t/main.bc,_foo, \
25; RUN:   -r=%t/foo.bc,_foo,px
26; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=PUBLIC
27
28; PUBLIC-NOT: call {{.*}}@llvm.public.type.test
29; PUBLIC-NOT: call {{.*}}@llvm.type.test
30;; We should have converted the type tests from both main and the imported
31;; copy of foo to non-public.
32; HIDDEN-NOT: call {{.*}}@llvm.public.type.test
33; HIDDEN: call {{.*}}@llvm.type.test
34; HIDDEN-NOT: call {{.*}}@llvm.public.type.test
35; HIDDEN: call {{.*}}@llvm.type.test
36
37;--- main.ll
38target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39target triple = "x86_64-apple-macosx10.9"
40
41define i32 @main(ptr %vtable) {
42entry:
43  %p = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS1A")
44  call void @llvm.assume(i1 %p)
45  call void @bar(ptr %vtable)
46  ret i32 0
47}
48
49define void @bar(ptr %vtable) {
50entry:
51  call void @foo(ptr %vtable)
52  ret void
53}
54
55declare void @foo(ptr %vtable)
56
57declare void @llvm.assume(i1)
58declare i1 @llvm.public.type.test(ptr, metadata)
59
60;--- foo.ll
61target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62target triple = "x86_64-apple-macosx10.9"
63
64define void @foo(ptr %vtable) {
65entry:
66  %p = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS1A")
67  call void @llvm.assume(i1 %p)
68  ret void
69}
70
71declare void @llvm.assume(i1)
72declare i1 @llvm.public.type.test(ptr, metadata)
73