[llvm] [SPIR-V] Fix environment resolution causing legalization crash (PR #179052)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 06:56:00 PST 2026


================
@@ -86,8 +87,8 @@ class SPIRVSubtarget : public SPIRVGenSubtargetInfo {
   void setEnv(SPIRVEnvType E) {
     if (E == Unknown)
       report_fatal_error("Unknown environment is not allowed.");
-    if (Env != Unknown)
-      report_fatal_error("Environment is already set.");
+    if (Env != Unknown && Env != E)
+      report_fatal_error("Environment is already set to a different value.");
 
     Env = E;
   }
----------------
s-perron wrote:

Is this function called anymore? I think the two calls to the function were removed, and we could simply remove it? 

It creates a problem. If someone were to call it the instruction sets would not be reinitialized properly. If we keep it we need to fix that up.

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


More information about the llvm-commits mailing list