Skip to content

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 farzonl and s-perron 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