Skip to content

Commit e78694e

Browse files
committed
[clang][SPIR-V] Addrspace of opencl_global should always be 1
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 5e67476 commit e78694e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

clang/lib/Basic/Targets/SPIR.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static const unsigned SPIRDefIsPrivMap[] = {
5858
// Used by both the SPIR and SPIR-V targets.
5959
static const unsigned SPIRDefIsGenMap[] = {
6060
4, // Default
61-
// OpenCL address space values for this map are dummy and they can't be used
62-
0, // opencl_global
61+
// Some OpenCL address space values for this map are dummy and they can't be used
62+
1, // opencl_global
6363
0, // opencl_local
6464
0, // opencl_constant
6565
0, // opencl_private
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fcuda-is-device -triple spirv32 -o - -emit-llvm -x cuda %s | FileCheck --check-prefix=CHECK-SPIRV32 %s
2+
// RUN: %clang_cc1 -fcuda-is-device -triple spirv64 -o - -emit-llvm -x cuda %s | FileCheck --check-prefix=CHECK-SPIRV64 %s
3+
4+
// CHECK-SPIRV32: @.str = private unnamed_addr addrspace(4) constant [13 x i8] c"Hello World\0A\00", align 1
5+
// CHECK-SPIRV64: @.str = private unnamed_addr addrspace(1) constant [13 x i8] c"Hello World\0A\00", align 1
6+
7+
extern "C" __attribute__((device)) int printf(const char* format, ...);
8+
9+
__attribute__((global)) void printf_kernel() {
10+
printf("Hello World\n");
11+
}

0 commit comments

Comments
 (0)