| 1 |
// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s |
| 2 |
// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s |
| 3 |
// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck -check-prefixes=CHECK-DEBUG %s |
| 4 |
// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=CHECK-DEBUG %s |
| 5 |
// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_device_enqueue,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s |
| 6 |
// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_device_enqueue,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s |
| 7 |
// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_device_enqueue,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck -check-prefixes=CHECK-DEBUG %s |
| 8 |
// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_device_enqueue,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=CHECK-DEBUG %s |
| 9 |
|
| 10 |
// SPIR: @__block_literal_global = internal addrspace(1) constant { i32, i32, ptr addrspace(4) } { i32 12, i32 4, ptr addrspace(4) addrspacecast (ptr @block_A_block_invoke to ptr addrspace(4)) } |
| 11 |
// AMDGCN: @__block_literal_global = internal addrspace(1) constant { i32, i32, ptr } { i32 16, i32 8, ptr @block_A_block_invoke } |
| 12 |
// COMMON-NOT: .str |
| 13 |
|
| 14 |
// SPIR-LABEL: define internal {{.*}}void @block_A_block_invoke(ptr addrspace(4) noundef %.block_descriptor, ptr addrspace(3) noundef %a) |
| 15 |
// AMDGCN-LABEL: define internal {{.*}}void @block_A_block_invoke(ptr noundef %.block_descriptor, ptr addrspace(3) noundef %a) |
| 16 |
void (^block_A)(local void *) = ^(local void *a) { |
| 17 |
return; |
| 18 |
}; |
| 19 |
|
| 20 |
// COMMON-LABEL: define {{.*}}void @foo() |
| 21 |
void foo(){ |
| 22 |
int i; |
| 23 |
// COMMON-NOT: %block.isa |
| 24 |
// COMMON-NOT: %block.flags |
| 25 |
// COMMON-NOT: %block.reserved |
| 26 |
// COMMON-NOT: %block.descriptor |
| 27 |
// SPIR: %[[block_size:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr addrspace(4), i32 }>, ptr %block, i32 0, i32 0 |
| 28 |
// AMDGCN: %[[block_size:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr, i32 }>, ptr %block{{.*}}, i32 0, i32 0 |
| 29 |
// SPIR: store i32 16, ptr %[[block_size]] |
| 30 |
// AMDGCN: store i32 20, ptr %[[block_size]] |
| 31 |
// SPIR: %[[block_align:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr addrspace(4), i32 }>, ptr %block, i32 0, i32 1 |
| 32 |
// AMDGCN: %[[block_align:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr, i32 }>, ptr %block{{.*}}, i32 0, i32 1 |
| 33 |
// SPIR: store i32 4, ptr %[[block_align]] |
| 34 |
// AMDGCN: store i32 8, ptr %[[block_align]] |
| 35 |
// SPIR: %[[block_invoke:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr addrspace(4), i32 }>, ptr %[[block:.*]], i32 0, i32 2 |
| 36 |
// SPIR: store ptr addrspace(4) addrspacecast (ptr @__foo_block_invoke to ptr addrspace(4)), ptr %[[block_invoke]] |
| 37 |
// SPIR: %[[block_captured:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr addrspace(4), i32 }>, ptr %[[block]], i32 0, i32 3 |
| 38 |
// SPIR: %[[i_value:.*]] = load i32, ptr %i |
| 39 |
// SPIR: store i32 %[[i_value]], ptr %[[block_captured]], |
| 40 |
// SPIR: %[[blk_gen_ptr:.*]] = addrspacecast ptr %[[block]] to ptr addrspace(4) |
| 41 |
// SPIR: store ptr addrspace(4) %[[blk_gen_ptr]], ptr %[[block_B:.*]], |
| 42 |
// SPIR: %[[block_literal:.*]] = load ptr addrspace(4), ptr %[[block_B]] |
| 43 |
// SPIR: call {{.*}}i32 @__foo_block_invoke(ptr addrspace(4) noundef %[[block_literal]]) |
| 44 |
// AMDGCN: %[[block_invoke:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr, i32 }>, ptr %[[block:.*]], i32 0, i32 2 |
| 45 |
// AMDGCN: store ptr @__foo_block_invoke, ptr %[[block_invoke]] |
| 46 |
// AMDGCN: %[[block_captured:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr, i32 }>, ptr %[[block]], i32 0, i32 3 |
| 47 |
// AMDGCN: %[[i_value:.*]] = load i32, ptr addrspace(5) %i |
| 48 |
// AMDGCN: store i32 %[[i_value]], ptr %[[block_captured]], |
| 49 |
// AMDGCN: store ptr %[[block]], ptr addrspace(5) %[[block_B:.*]], |
| 50 |
// AMDGCN: %[[block_literal:.*]] = load ptr, ptr addrspace(5) %[[block_B]] |
| 51 |
// AMDGCN: call {{.*}}i32 @__foo_block_invoke(ptr noundef %[[block_literal]]) |
| 52 |
|
| 53 |
int (^ block_B)(void) = ^{ |
| 54 |
return i; |
| 55 |
}; |
| 56 |
block_B(); |
| 57 |
} |
| 58 |
|
| 59 |
// SPIR-LABEL: define internal {{.*}}i32 @__foo_block_invoke(ptr addrspace(4) noundef %.block_descriptor) |
| 60 |
// SPIR: %[[block_capture_addr:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr addrspace(4), i32 }>, ptr addrspace(4) %.block_descriptor, i32 0, i32 3 |
| 61 |
// SPIR: %[[block_capture:.*]] = load i32, ptr addrspace(4) %[[block_capture_addr]] |
| 62 |
// AMDGCN-LABEL: define internal {{.*}}i32 @__foo_block_invoke(ptr noundef %.block_descriptor) |
| 63 |
// AMDGCN: %[[block_capture_addr:.*]] = getelementptr inbounds nuw <{ i32, i32, ptr, i32 }>, ptr %.block_descriptor, i32 0, i32 3 |
| 64 |
// AMDGCN: %[[block_capture:.*]] = load i32, ptr %[[block_capture_addr]] |
| 65 |
|
| 66 |
// COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel |
| 67 |
|
| 68 |
// COMMON-LABEL: define {{.*}}@call_block |
| 69 |
// call {{.*}}@__call_block_block_invoke |
| 70 |
int call_block() { |
| 71 |
return ^int(int num) { return num; } (11); |
| 72 |
} |
| 73 |
|
| 74 |
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size" |
| 75 |
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align" |
| 76 |
|
| 77 |
// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa" |
| 78 |
// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags" |
| 79 |
// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved" |
| 80 |
// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr" |