[clang] [HLSL][SPIR-V] Change SPV AS map for groupshared (PR #143519)
Nathan Gauër via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 08:29:18 PDT 2025
https://github.com/Keenuts updated https://github.com/llvm/llvm-project/pull/143519
>From 9eb9d28d844e4427da5c9cc4f13b9263aae48ece Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= <brioche at google.com>
Date: Tue, 10 Jun 2025 14:33:20 +0200
Subject: [PATCH] [HLSL][SPIR-V] Change SPV AS map for groupshared
The previous mapping we setting the hlsl_groupshared AS to 0,
which translated to either Generic or Function.
Changing this to 3, which translated to Workgroup.
Related to #142804
---
clang/lib/Basic/Targets/SPIR.h | 4 ++--
clang/test/CodeGenHLSL/group_shared.hlsl | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 0eaf82eee756b..b416a01f0f374 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -46,7 +46,7 @@ static const unsigned SPIRDefIsPrivMap[] = {
0, // ptr32_sptr
0, // ptr32_uptr
0, // ptr64
- 0, // hlsl_groupshared
+ 3, // hlsl_groupshared
12, // hlsl_constant
10, // hlsl_private
11, // hlsl_device
@@ -82,7 +82,7 @@ static const unsigned SPIRDefIsGenMap[] = {
0, // ptr32_sptr
0, // ptr32_uptr
0, // ptr64
- 0, // hlsl_groupshared
+ 3, // hlsl_groupshared
0, // hlsl_constant
10, // hlsl_private
11, // hlsl_device
diff --git a/clang/test/CodeGenHLSL/group_shared.hlsl b/clang/test/CodeGenHLSL/group_shared.hlsl
index 4b2e2beba4f12..a562e75b34881 100644
--- a/clang/test/CodeGenHLSL/group_shared.hlsl
+++ b/clang/test/CodeGenHLSL/group_shared.hlsl
@@ -3,6 +3,10 @@
// RUN: dxil-pc-shadermodel6.3-library %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN: spirv-unknown-vulkan1.3-compute %s \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
// Make sure groupshared translated into address space 3.
// CHECK:@a = addrspace(3) global [10 x float]
More information about the cfe-commits
mailing list