1 ; RUN: opt -passes=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) }
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" }
10 ; Function Attrs: alwaysinline norecurse nounwind readonly
11 define i32 @bl0_block_invoke(ptr addrspace(4) nocapture readnone, ptr addrspace(1) nocapture readonly) #0 {
13 %2 = load i32, ptr addrspace(1) %1, align 4
14 %mul = shl nsw i32 %2, 1
18 ; Function Attrs: alwaysinline nounwind
19 define i32 @f0(ptr addrspace(1), ptr addrspace(4)) #1 {
21 %2 = getelementptr inbounds %struct.__block_literal_generic, ptr addrspace(4) %1, i64 0, i32 3
22 %3 = load ptr, ptr addrspace(4) %2, align 8
23 %call = tail call i32 %3(ptr addrspace(4) %1, ptr addrspace(1) %0) #2
27 ; CHECK-LABEL: define void @f1
28 ; CHECK: %1 = load ptr, ptr addrspace(4) getelementptr inbounds nuw (i8, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__aaa_struct_ptr to ptr addrspace(4)), i64 16), align 8
30 ; Function Attrs: alwaysinline nounwind
31 define void @f1(ptr addrspace(1)) #1 {
33 %call = tail call i32 @f0(ptr addrspace(1) %0, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__aaa_struct_ptr to ptr addrspace(4))) #3
34 store i32 %call, ptr addrspace(1) %0, align 4
35 %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
36 store i32 %call1, ptr addrspace(1) %0, align 4
40 ; Function Attrs: alwaysinline norecurse nounwind readonly
41 define i32 @__f1_block_invoke(ptr addrspace(4) nocapture readnone, ptr addrspace(1) nocapture readonly) #0 {
43 %2 = load i32, ptr addrspace(1) %1, align 4
44 %add = add nsw i32 %2, 1
48 attributes #0 = { alwaysinline norecurse nounwind readonly }
49 attributes #1 = { alwaysinline nounwind }
50 attributes #2 = { nobuiltin nounwind }
51 attributes #3 = { nobuiltin }