[clang] Add spirv-val compilation step when targeting SPIR-V (PR #188150)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 12:25:11 PDT 2026


================
@@ -384,12 +408,20 @@ HLSLToolChain::HLSLToolChain(const Driver &D, const llvm::Triple &Triple,
   if (Args.hasArg(options::OPT_dxc_validator_path_EQ))
     getProgramPaths().push_back(
         Args.getLastArgValue(options::OPT_dxc_validator_path_EQ).str());
+  if (Args.hasArg(options::OPT_spirv_validator_path_EQ))
+    getProgramPaths().push_back(
+        Args.getLastArgValue(options::OPT_spirv_validator_path_EQ).str());
 }
 
 Tool *clang::driver::toolchains::HLSLToolChain::getTool(
     Action::ActionClass AC) const {
   switch (AC) {
   case Action::BinaryAnalyzeJobClass:
+    if (getTriple().isSPIRV()) {
+      if (!SPIRVValidator)
+        SPIRVValidator.reset(new tools::hlsl::SPIRV_Validator(*this));
+      return SPIRVValidator.get();
+    }
     if (!Validator)
       Validator.reset(new tools::hlsl::Validator(*this));
     return Validator.get();
----------------
bogner wrote:

We can only ever have one validator, and the spirv validator logic needs to look a tthe triple anyway. I wonder if it would make more sense to just have one `hlsl::Validator` type, and have it invoke spirv-val or dxv as appropriate depending on the target.

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


More information about the cfe-commits mailing list