[clang] [llvm] [SPIRV] Add size optimisation for AMDGCN flavoured SPIR-V (PR #228188)

Marcos Maronas via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 15 01:07:35 PDT 2026


================
@@ -1113,6 +1154,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
     } else {
       MPM.addPass(PB.buildPerModuleDefaultPipeline(Level));
     }
+  } else if (mapToLevel(CodeGenOpts) > OptimizationLevel::O0 &&
+             CodeGenOpts.AMDGCNSPIRVSizeOptimization) {
+    if (!TargetTriple.isSPIRV() ||
+        (TargetTriple.getVendor() != llvm::Triple::VendorType::AMD))
+      Diags.Report(diag::err_opt_not_valid_on_target)
----------------
maarquitos14 wrote:

Sorry for the confusion, I actually meant merging this check with the `else if`, so that the passes are only added if we're targeting an AMD+SPIRV triple. Otherwise, if the new flag is passed but the triple is not AMD+SPIRV, we simply ignore it. Do you think there is any danger in doing that?

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


More information about the cfe-commits mailing list