Skip to content

[clang][NFCI] Fix getGridValues for unsupported targets #131023

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
Mar 13, 2025

Conversation

sarnex
Copy link
Member

@sarnex sarnex commented Mar 12, 2025

I broke this in f3cd223, I should have added this to the SPIRV64 subclass, but I accidentally added it to base TargetInfo.

Using an unsupported target should error in the driver way before this though.

@sarnex sarnex marked this pull request as ready for review March 12, 2025 20:57
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2025

@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)

Changes

I broke this in f3cd223, I should have added this to the SPIRV64 subclass, but I accidentally added it to base TargetInfo.


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

2 Files Affected:

  • (modified) clang/include/clang/Basic/TargetInfo.h (+1-1)
  • (modified) clang/lib/Basic/Targets/SPIR.h (+4)
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index d136b459e9cd4..497d68779b92b 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1675,7 +1675,7 @@ class TargetInfo : public TransferrableTargetInfo,
   // access target-specific GPU grid values that must be consistent between
   // host RTL (plugin), deviceRTL and clang.
   virtual const llvm::omp::GV &getGridValue() const {
-    return llvm::omp::SPIRVGridValues;
+    llvm_unreachable("getGridValue not implemented on this target");
   }
 
   /// Retrieve the name of the platform as it is used in the
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 610efa1fe00d9..78505d66d6f2f 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -370,6 +370,10 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo {
 
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override;
+
+  const llvm::omp::GV &getGridValue() const override {
+    return llvm::omp::SPIRVGridValues;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final

@sarnex sarnex requested a review from jhuber6 March 12, 2025 20:58
@sarnex sarnex merged commit 7a5e4f5 into llvm:main Mar 13, 2025
15 checks passed
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
I broke this in
llvm@f3cd223,
I should have added this to the `SPIRV64` subclass, but I accidentally
added it to base `TargetInfo`.

Using an unsupported target should error in the driver way before this
though.

Signed-off-by: Sarnie, Nick <[email protected]>
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.

3 participants