[llvm] [SPIRV] Change how to detect OpenCL/Vulkan Env and update tests accordingly. (PR #129689)

Marcos Maronas via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 08:30:34 PDT 2025


================
@@ -83,6 +83,14 @@ SPIRVSubtarget::SPIRVSubtarget(const Triple &TT, const std::string &CPU,
   }
   OpenCLVersion = VersionTuple(2, 2);
 
+  // Set the environment based on the target triple.
+  if (TargetTriple.getOS() == Triple::Vulkan)
+    Env = Shader;
+  else if (TargetTriple.getEnvironment() == Triple::OpenCL)
+    Env = Kernel;
+  else
+    Env = Unknown;
----------------
maarquitos14 wrote:

I don't think this should be an error. We have some heuristics to try and set the environment later by analyzing the module, e.g. if we find `hlsl.shader` attribute, then we set environment to Shader.

Additionally, @bader requested to keep the current behavior where triples like `spirv[32|64]-unknown-unknown` target OpenCL/Kernel environment in https://github.com/llvm/llvm-project/pull/129689#discussion_r2032017204. If we report a fatal error here, the current behavior would crash. 

https://github.com/llvm/llvm-project/pull/129689


More information about the llvm-commits mailing list