| 1 |
// RUN: %clang_cc1 %s -triple "spirv32-unknown-unknown" -fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV32 |
| 2 |
// RUN: %clang_cc1 %s -triple "spirv64-unknown-unknown" -fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV64 |
| 3 |
|
| 4 |
// SPIRV32: target triple = "spirv32-unknown-unknown" |
| 5 |
// SPIRV64: target triple = "spirv64-unknown-unknown" |
| 6 |
|
| 7 |
typedef struct { |
| 8 |
char c; |
| 9 |
void *v; |
| 10 |
void *v2; |
| 11 |
} my_st; |
| 12 |
|
| 13 |
kernel void foo(global long *arg) { |
| 14 |
#if __SPIRV32__ == 1 |
| 15 |
int res1[sizeof(my_st) == 12 ? 1 : -1]; // expected-no-diagnostics |
| 16 |
int res2[sizeof(void *) == 4 ? 1 : -1]; // expected-no-diagnostics |
| 17 |
int res3[sizeof(arg) == 4 ? 1 : -1]; // expected-no-diagnostics |
| 18 |
#elif __SPIRV64__ == 1 |
| 19 |
int res1[sizeof(my_st) == 24 ? 1 : -1]; // expected-no-diagnostics |
| 20 |
int res2[sizeof(void *) == 8 ? 1 : -1]; // expected-no-diagnostics |
| 21 |
int res3[sizeof(arg) == 8 ? 1 : -1]; // expected-no-diagnostics |
| 22 |
#endif |
| 23 |
my_st *tmp = 0; |
| 24 |
|
| 25 |
// SPIRV32: store i64 4, ptr addrspace(1) |
| 26 |
// SPIRV64: store i64 8, ptr addrspace(1) |
| 27 |
arg[0] = (long)(&tmp->v); |
| 28 |
// SPIRV32: store i64 8, ptr addrspace(1) |
| 29 |
// SPIRV64: store i64 16, ptr addrspace(1) |
| 30 |
arg[1] = (long)(&tmp->v2); |
| 31 |
} |