xref: /llvm-project/llvm/test/ThinLTO/X86/cfi-icall-only-defuse.ll (revision d5d3eb16b7ab72529c83dacb2889811491e48909)
1; Verifies that only functions defined or used by each module make it into the
2; CFI functions sets in that module's distributed index.
3; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t1.bc
4; RUN: opt -thinlto-bc -thinlto-split-lto-unit %S/Inputs/cfi-icall-only-bazqux.ll -o %t2.bc
5; RUN: llvm-lto2 run  -thinlto-distributed-indexes %t1.bc %t2.bc -o %t.out \
6; RUN:   -r %t1.bc,bar,plx \
7; RUN:   -r %t1.bc,baz,x   \
8; RUN:   -r %t1.bc,f,plx   \
9; RUN:   -r %t1.bc,foo,plx \
10; RUN:   -r %t2.bc,bar,x   \
11; RUN:   -r %t2.bc,baz,plx \
12; RUN:   -r %t2.bc,g,plx   \
13; RUN:   -r %t2.bc,qux,plx
14; RUN: llvm-bcanalyzer -dump %t1.bc.thinlto.bc | FileCheck %s --check-prefix=FOOBAZ
15; RUN: llvm-bcanalyzer -dump %t2.bc.thinlto.bc | FileCheck %s --check-prefix=BARQUX
16
17target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
18target triple = "x86_64-unknown-linux-gnu"
19
20declare !type !0 i8 @baz(ptr)
21declare i1 @llvm.type.test(ptr %ptr, metadata %type) nounwind readnone
22
23define i8 @foo(ptr %p) !type !0 {
24  %x = call i1 @llvm.type.test(ptr %p, metadata !"t1")
25  %1 = select i1 %x, i8 0, i8 1
26  ret i8 %1
27}
28
29define i8 @bar(ptr %p) !type !0 {
30  %x = call i1 @llvm.type.test(ptr %p, metadata !"t1")
31  ret i8 2
32}
33
34define i8 @f(i1 %i, ptr %p) {
35  %1 = select i1 %i, ptr @foo, ptr @baz
36  %2 = call i8 %1(ptr %p)
37  ret i8 %2
38}
39
40!0 = !{i64 0, !"t1"}
41
42; FOOBAZ:   <GLOBALVAL_SUMMARY_BLOCK
43; FOOBAZ:     <CFI_FUNCTION_DEFS op0=0 op1=3 op2=3 op3=3 op4=6 op5=3/>
44; FOOBAZ:     <TYPE_ID op0=9 op1=2 op2=4 op3=7 op4=0 op5=0 op6=0 op7=0/>
45; FOOBAZ:   </GLOBALVAL_SUMMARY_BLOCK>
46; FOOBAZ:      <STRTAB_BLOCK
47; FOOBAZ-NEXT:   <BLOB abbrevid=4/> blob data = 'barbazfoot1'
48; FOOBAZ-NEXT: </STRTAB_BLOCK>
49
50; BARQUX:   <GLOBALVAL_SUMMARY_BLOCK
51; BARQUX:     <CFI_FUNCTION_DEFS op0=0 op1=3 op2=3 op3=3 op4=6 op5=3/>
52; BARQUX:     <TYPE_ID op0=9 op1=2 op2=4 op3=7 op4=0 op5=0 op6=0 op7=0/>
53; BARQUX:   </GLOBALVAL_SUMMARY_BLOCK>
54; BARQUX:      <STRTAB_BLOCK
55; BARQUX-NEXT:   <BLOB abbrevid=4/> blob data = 'barbazquxt1'
56; BARQUX-NEXT: </STRTAB_BLOCK>
57