https://github.com/sarnex updated 
https://github.com/llvm/llvm-project/pull/136753

>From e78694e52dfdcb6e2b085173952064a806d1d1a8 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sar...@intel.com>
Date: Tue, 22 Apr 2025 12:57:36 -0700
Subject: [PATCH 1/2] [clang][SPIR-V] Addrspace of opencl_global should always
 be 1

Signed-off-by: Sarnie, Nick <nick.sar...@intel.com>
---
 clang/lib/Basic/Targets/SPIR.h        |  4 ++--
 clang/test/CodeGenCUDASPIRV/printf.cu | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGenCUDASPIRV/printf.cu

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 4509748589b76..577da6fd93d13 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -58,8 +58,8 @@ static const unsigned SPIRDefIsPrivMap[] = {
 // Used by both the SPIR and SPIR-V targets.
 static const unsigned SPIRDefIsGenMap[] = {
     4, // Default
-    // OpenCL address space values for this map are dummy and they can't be 
used
-    0, // opencl_global
+    // Some OpenCL address space values for this map are dummy and they can't 
be used
+    1, // opencl_global
     0, // opencl_local
     0, // opencl_constant
     0, // opencl_private
diff --git a/clang/test/CodeGenCUDASPIRV/printf.cu 
b/clang/test/CodeGenCUDASPIRV/printf.cu
new file mode 100644
index 0000000000000..936e920f4a755
--- /dev/null
+++ b/clang/test/CodeGenCUDASPIRV/printf.cu
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv32 -o - -emit-llvm -x cuda %s 
 | FileCheck --check-prefix=CHECK-SPIRV32 %s
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv64 -o - -emit-llvm -x cuda %s 
 | FileCheck --check-prefix=CHECK-SPIRV64 %s
+
+// CHECK-SPIRV32: @.str = private unnamed_addr addrspace(4) constant [13 x i8] 
c"Hello World\0A\00", align 1
+// CHECK-SPIRV64: @.str = private unnamed_addr addrspace(1) constant [13 x i8] 
c"Hello World\0A\00", align 1
+
+extern "C" __attribute__((device)) int printf(const char* format, ...);
+
+__attribute__((global)) void printf_kernel() {
+  printf("Hello World\n");
+}

>From 68a8341a086ade83201a3da08d9a04dc8b424a1c Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <nick.sar...@intel.com>
Date: Tue, 22 Apr 2025 13:01:16 -0700
Subject: [PATCH 2/2] format

Signed-off-by: Sarnie, Nick <nick.sar...@intel.com>
---
 clang/lib/Basic/Targets/SPIR.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 577da6fd93d13..310ef9f2df2c6 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -58,7 +58,8 @@ static const unsigned SPIRDefIsPrivMap[] = {
 // Used by both the SPIR and SPIR-V targets.
 static const unsigned SPIRDefIsGenMap[] = {
     4, // Default
-    // Some OpenCL address space values for this map are dummy and they can't 
be used
+    // Some OpenCL address space values for this map are dummy and they can't 
be
+    // used
     1, // opencl_global
     0, // opencl_local
     0, // opencl_constant

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to