Skip to content

Commit 52a9649

Browse files
authored
[clang][SPIR-V] Addrspace of opencl_global should always be 1 (#136753)
This fixes a CUDA SPIR-V regression introduced in #134399. --------- Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
1 parent ed866d9 commit 52a9649

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/lib/Basic/Targets/SPIR.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ 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
62+
// used
63+
1, // opencl_global
6364
0, // opencl_local
6465
0, // opencl_constant
6566
0, // opencl_private

clang/test/CodeGenCUDASPIRV/printf.cu

+11
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)