Skip to content

[HIP] Emit the CUID value in the module with the new driver #144570

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
Jun 19, 2025

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Jun 17, 2025

Summary:
This is a weird point of divergence that was not updated when the new driver
switched to using the CUID method, which is also apparently critical
for SPIR-V compilation not failing? Somehow if we don't emit this global
than the llvm.compiler.used global uses AS(0) which makes SPIR-V
unhappy, but with this global it's AS(4) which makes it happy. Either
way, this should be fixed.

Summary:
This is a weird point of divergence, which is also apparently critical
for SPIR-V compilation not failing? Somehow if we don't emit this global
than the `llvm.compiler.used` global uses AS(0) which makes SPIR-V
unhappy, but with this global it's AS(4) which makes it happy. Either
way, this should be fixed.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Jun 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 17, 2025

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)

Changes

Summary:
This is a weird point of divergence, which is also apparently critical
for SPIR-V compilation not failing? Somehow if we don't emit this global
than the llvm.compiler.used global uses AS(0) which makes SPIR-V
unhappy, but with this global it's AS(4) which makes it happy. Either
way, this should be fixed.


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

1 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index c036902b0b130..0f075b747eacf 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -969,7 +969,7 @@ void CodeGenModule::Release() {
         llvm::ConstantArray::get(ATy, UsedArray), "__clang_gpu_used_external");
     addCompilerUsedGlobal(GV);
   }
-  if (LangOpts.HIP && !getLangOpts().OffloadingNewDriver) {
+  if (LangOpts.HIP) {
     // Emit a unique ID so that host and device binaries from the same
     // compilation unit can be associated.
     auto *GV = new llvm::GlobalVariable(

@jhuber6 jhuber6 requested review from jplehr and jdoerfert June 17, 2025 18:52
@arsenm
Copy link
Contributor

arsenm commented Jun 19, 2025

llvm.compiler.used global uses AS(0) which makes SPIR-V unhappy, but with this global it's AS(4) which makes it happy. Either way, this should be fixed.

llvm.used and llvm.compiler.used should universally use addrspace(0) and SPIRV should be fixed to not break on this

@jhuber6
Copy link
Contributor Author

jhuber6 commented Jun 19, 2025

llvm.compiler.used global uses AS(0) which makes SPIR-V unhappy, but with this global it's AS(4) which makes it happy. Either way, this should be fixed.

llvm.used and llvm.compiler.used should universally use addrspace(0) and SPIRV should be fixed to not break on this

Definitely, but this should probably land anyway since it's divergent for no reason.

@shiltian
Copy link
Contributor

No test is needed?

Copy link
Contributor

@AlexVlx AlexVlx left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@jhuber6 jhuber6 merged commit 09e794c into llvm:main Jun 19, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants