[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:01 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:

Now that I think about it more. Can you have this function call initAvailableExtInstSets and reinitialize the legalizer. Then both places that set Env should call this function. Having 1 place that sets Env could help if we find other things that need to be reset based on the env.

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


More information about the llvm-commits mailing list