Skip to content

[clang][SPIR-V] Fix OpenCL addrspace mapping when using non-zero default AS #137187

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 1 commit into from
Apr 28, 2025

Conversation

sarnex
Copy link
Member

@sarnex sarnex commented Apr 24, 2025

Based on feedback from #136753, remove the dummy values for OpenCL and make them match the zero default AS map.

@sarnex sarnex marked this pull request as ready for review April 24, 2025 15:13
@sarnex sarnex requested review from MrSidims and AlexVlx April 24, 2025 15:13
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 24, 2025

@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)

Changes

Based on feedback from #136753, remove the dummy values for OpenCL and make them match the zero default AS map.


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

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/SPIR.h (+5-7)
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 310ef9f2df2c6..bf249e271a870 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -58,15 +58,13 @@ 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
     1, // opencl_global
-    0, // opencl_local
-    0, // opencl_constant
+    3, // opencl_local
+    2, // opencl_constant
     0, // opencl_private
-    0, // opencl_generic
-    0, // opencl_global_device
-    0, // opencl_global_host
+    4, // opencl_generic
+    5, // opencl_global_device
+    6, // opencl_global_host
     // cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V
     // translation). This mapping is enabled when the language mode is HIP.
     1, // cuda_device

@sarnex
Copy link
Member Author

sarnex commented Apr 28, 2025

Ping @AlexVlx @MrSidims thanks :)

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is LGTM, but I'm starting to wonder, if those maps (with the only difference in default) can be unified and setAddressSpaceMap function changed appropriately.

@sarnex
Copy link
Member Author

sarnex commented Apr 28, 2025

Probably yes, but I'd prefer to leave that to future work, I have enough on my plate :)

@sarnex sarnex merged commit f9ee5ce into llvm:main Apr 28, 2025
16 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…ult AS (llvm#137187)

Based on feedback from llvm#136753,
remove the dummy values for OpenCL and make them match the zero default
AS map.

Signed-off-by: Sarnie, Nick <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…ult AS (llvm#137187)

Based on feedback from llvm#136753,
remove the dummy values for OpenCL and make them match the zero default
AS map.

Signed-off-by: Sarnie, Nick <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…ult AS (llvm#137187)

Based on feedback from llvm#136753,
remove the dummy values for OpenCL and make them match the zero default
AS map.

Signed-off-by: Sarnie, Nick <[email protected]>
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
…ult AS (llvm#137187)

Based on feedback from llvm#136753,
remove the dummy values for OpenCL and make them match the zero default
AS map.

Signed-off-by: Sarnie, Nick <[email protected]>
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
…ult AS (llvm#137187)

Based on feedback from llvm#136753,
remove the dummy values for OpenCL and make them match the zero default
AS map.

Signed-off-by: Sarnie, Nick <[email protected]>
@yingcong-wu
Copy link
Contributor

Hi @sarnex , this change is crucial for the device sanitizers since it addresses a long-standing OMP related issue of us. Please help keep this change. Thanks.

@sarnex
Copy link
Member Author

sarnex commented May 22, 2025

@yingcong-wu I'm glad this fixes something! I don't think this change was reverted anywhere, so could you let me know what you mean by helping you keep this change? Thanks

@yingcong-wu
Copy link
Contributor

Hi @sarnex , I just want to let you know that this change is important to us, and want to express our gratitude to you in the previous comment.

@sarnex
Copy link
Member Author

sarnex commented May 23, 2025

Ah ok thank you! I'm surprised this work effects anything as I was mostly doing it for upstream OMP SPV which doesnt' work yet :)

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants