1; RUN: opt -always-inline -S %s | FileCheck %s
2%0 = type { i64, i64, ptr addrspace(1), ptr addrspace(1) }
3%__aaa_struct = type { { ptr, i32, i32, ptr, ptr addrspace(1) }, %0, [17 x i8], { ptr, i32, i32, ptr, ptr addrspace(1) }, %0, [18 x i8] }
4%struct.__block_descriptor = type { i64, i64 }
5%struct.__block_literal_generic = type { ptr, i32, i32, ptr, ptr addrspace(1) }
6
7@__aaa_struct_ptr = external addrspace(1) global %__aaa_struct
8@__aaa_const_init = constant %__aaa_struct { { ptr, i32, i32, ptr, ptr addrspace(1) } { ptr null, i32 1342177280, i32 0, ptr @bl0_block_invoke, ptr addrspace(1) getelementptr inbounds (%__aaa_struct, ptr addrspace(1) @__aaa_struct_ptr, i32 0, i32 1) }, %0 { i64 0, i64 32, ptr addrspace(1) getelementptr inbounds (%__aaa_struct, ptr addrspace(1) @__aaa_struct_ptr, i32 0, i32 2, i32 0), ptr addrspace(1) null }, [17 x i8] c"bl0_block_invoke\00", { ptr, i32, i32, ptr, ptr addrspace(1) } { ptr null, i32 1342177280, i32 0, ptr @__f1_block_invoke, ptr addrspace(1) getelementptr inbounds (%__aaa_struct, ptr addrspace(1) @__aaa_struct_ptr, i32 0, i32 4) }, %0 { i64 0, i64 32, ptr addrspace(1) getelementptr inbounds (%__aaa_struct, ptr addrspace(1) @__aaa_struct_ptr, i32 0, i32 5, i32 0), ptr addrspace(1) null }, [18 x i8] c"__f1_block_invoke\00" }
9
10; Function Attrs: alwaysinline norecurse nounwind readonly
11define i32 @bl0_block_invoke(ptr addrspace(4) nocapture readnone, ptr addrspace(1) nocapture readonly) #0 {
12entry:
13  %2 = load i32, ptr addrspace(1) %1, align 4
14  %mul = shl nsw i32 %2, 1
15  ret i32 %mul
16}
17
18; Function Attrs: alwaysinline nounwind
19define i32 @f0(ptr addrspace(1), ptr addrspace(4)) #1 {
20entry:
21  %2 = getelementptr inbounds %struct.__block_literal_generic, ptr addrspace(4) %1, i64 0, i32 3
22  %3 = bitcast ptr addrspace(4) %1 to ptr addrspace(4)
23  %4 = bitcast ptr addrspace(4) %2 to ptr addrspace(4)
24  %5 = load ptr, ptr addrspace(4) %4, align 8
25  %call = tail call i32 %5(ptr addrspace(4) %3, ptr addrspace(1) %0) #2
26  ret i32 %call
27}
28
29; CHECK-LABEL: define void @f1
30; CHECK: %1 = load ptr, ptr addrspace(4) getelementptr inbounds (i8, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__aaa_struct_ptr to ptr addrspace(4)), i64 16), align 8
31
32; Function Attrs: alwaysinline nounwind
33define void @f1(ptr addrspace(1)) #1 {
34entry:
35  %call = tail call i32 @f0(ptr addrspace(1) %0, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__aaa_struct_ptr to ptr addrspace(4))) #3
36  store i32 %call, ptr addrspace(1) %0, align 4
37  %call1 = tail call i32 @f0(ptr addrspace(1) %0, ptr addrspace(4) addrspacecast (ptr addrspace(1) getelementptr inbounds (%__aaa_struct, ptr addrspace(1) @__aaa_struct_ptr, i32 0, i32 3) to ptr addrspace(4))) #3
38  store i32 %call1, ptr addrspace(1) %0, align 4
39  ret void
40}
41
42; Function Attrs: alwaysinline norecurse nounwind readonly
43define i32 @__f1_block_invoke(ptr addrspace(4) nocapture readnone, ptr addrspace(1) nocapture readonly) #0 {
44entry:
45  %2 = load i32, ptr addrspace(1) %1, align 4
46  %add = add nsw i32 %2, 1
47  ret i32 %add
48}
49
50attributes #0 = { alwaysinline norecurse nounwind readonly }
51attributes #1 = { alwaysinline nounwind }
52attributes #2 = { nobuiltin nounwind }
53attributes #3 = { nobuiltin }
54