xref: /llvm-project/llvm/test/Bitcode/blockaddress-users.ll (revision 23ec5782c3cc0d77b5e44285e5124cd4a3ffeeef)
1; RUN: llvm-as %s -o %t.bc
2; RUN: llvm-bcanalyzer -dump %t.bc | FileCheck %s
3; RUN: llvm-dis %t.bc
4
5; There's a curious case where blockaddress constants may refer to functions
6; outside of the function they're used in. There's a special bitcode function
7; code, FUNC_CODE_BLOCKADDR_USERS, used to signify that this is the case.
8
9; The intent of this test is two-fold:
10; 1. Ensure we produce BLOCKADDR_USERS bitcode function code on the first fn,
11;    @repro, since @fun and @fun2 both refer to @repro via blockaddress
12;    constants.
13; 2. Ensure we can round-trip serializing+desearlizing such case.
14
15; CHECK: <FUNCTION_BLOCK
16; CHECK: <BLOCKADDR_USERS op0=2 op1=1
17; CHECK: <FUNCTION_BLOCK
18; CHECK: <FUNCTION_BLOCK
19
20define void @repro() {
21  br label %label
22
23label:
24  call void @fun()
25  ret void
26}
27
28define void @fun() noinline {
29  call void @f(i8* blockaddress(@repro, %label))
30  ret void
31}
32
33define void @fun2() noinline {
34  call void @f(i8* blockaddress(@repro, %label))
35  ret void
36}
37
38declare void @f(i8*)
39