1// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn < %s | FileCheck %s --check-prefixes=COMMON,AMDGPU 2// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir-unknown-unknown" < %s | FileCheck %s --check-prefixes=COMMON,SPIR32,SPIR 3// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" < %s | FileCheck %s --check-prefixes=COMMON,SPIR64,SPIR 4// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -debug-info-kind=limited -gno-column-info -emit-llvm -o - -triple amdgcn < %s | FileCheck %s --check-prefixes=CHECK-DEBUG 5 6// Check that the enqueue_kernel array temporary is in the entry block to avoid 7// a dynamic alloca 8 9typedef struct {int a;} ndrange_t; 10 11kernel void test(int i) { 12// AMDGPU-LABEL: define {{.*}} amdgpu_kernel void @test 13// SPIR-LABEL: define {{.*}} spir_kernel void @test 14 15// COMMON-LABEL: entry: 16// AMDGPU: %block_sizes = alloca [1 x i64] 17// SPIR32: %block_sizes = alloca [1 x i32] 18// SPIR64: %block_sizes = alloca [1 x i64] 19// COMMON-LABEL: if.then: 20// COMMON-NOT: alloca 21// CHECK-DEBUG: getelementptr {{.*}} %block_sizes{{.*}}, {{.*}} !dbg ![[TEMPLOCATION:[0-9]+]] 22// COMMON-LABEL: if.end 23 queue_t default_queue; 24 unsigned flags = 0; 25 ndrange_t ndrange; 26 if (i) 27 enqueue_kernel(default_queue, flags, ndrange, ^(local void *a) { }, 32); 28} 29 30// AMDGPU-LABEL: define internal void @__test_block_invoke( 31// SPIR-LABEL: define internal spir_func void @__test_block_invoke( 32 33// AMDGPU-LABEL: define internal amdgpu_kernel void @__test_block_invoke_kernel 34// SPIR-LABEL: define spir_kernel void @__test_block_invoke_kernel 35 36// Check that the temporary is scoped to the `if` 37 38// CHECK-DEBUG: ![[TESTFILE:[0-9]+]] = !DIFile(filename: "<stdin>" 39// CHECK-DEBUG: ![[TESTSCOPE:[0-9]+]] = distinct !DISubprogram(name: "test", {{.*}} file: ![[TESTFILE]] 40// CHECK-DEBUG: ![[IFSCOPE:[0-9]+]] = distinct !DILexicalBlock(scope: ![[TESTSCOPE]], file: ![[TESTFILE]], line: 26) 41// CHECK-DEBUG: ![[TEMPLOCATION]] = !DILocation(line: 27, scope: ![[IFSCOPE]]) 42