Skip to content

[HLSL][SPIR-V] Change SPV AS map for groupshared #143519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025

Conversation

Keenuts
Copy link
Contributor

@Keenuts Keenuts commented Jun 10, 2025

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

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 llvm#142804
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support labels Jun 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-hlsl

Author: Nathan Gauër (Keenuts)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/143519.diff

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/SPIR.h (+2-2)
  • (modified) clang/test/CodeGenHLSL/group_shared.hlsl (+4)
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]
 

@Keenuts Keenuts requested review from s-perron and farzonl June 10, 2025 12:38
@Keenuts Keenuts merged commit 33fee56 into llvm:main Jun 11, 2025
7 checks passed
@Keenuts Keenuts deleted the fix-groupshared-as branch June 11, 2025 12:22
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
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 llvm#142804
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
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 llvm#142804
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category HLSL HLSL Language Support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants