https://github.com/sarnex created https://github.com/llvm/llvm-project/pull/120266
Currently we produce SPIR-V text with `spirv-dis` but assemble it with `llvm-spirv`. The SPIR-V text format is different between the tools so the assemble fails. We need to use the same tool for both, and since `SPIRV-Tools` is technically an optional runtime dependency, just use `llvm-spirv` since that's already required. Once we are using the SPIR-V backend we should be able to get rid of this. >From 998827f68bb2f9c1ca43f1132e109406db842880 Mon Sep 17 00:00:00 2001 From: "Sarnie, Nick" <nick.sar...@intel.com> Date: Tue, 17 Dec 2024 08:52:49 -0800 Subject: [PATCH] [Driver][SPIR-V] Use consistent tools to convert between text and binary form Signed-off-by: Sarnie, Nick <nick.sar...@intel.com> --- clang/lib/Driver/ToolChains/SPIRV.cpp | 5 ++++- clang/test/Driver/spirv-toolchain.cl | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp index 659da5c7f25aa9..c84b23611bcfa6 100644 --- a/clang/lib/Driver/ToolChains/SPIRV.cpp +++ b/clang/lib/Driver/ToolChains/SPIRV.cpp @@ -28,8 +28,11 @@ void SPIRV::constructTranslateCommand(Compilation &C, const Tool &T, if (Input.getType() == types::TY_PP_Asm) CmdArgs.push_back("-to-binary"); + + // The text output from spirv-dis is not in the format expected + // by llvm-spirv, so use the text output from llvm-spirv. if (Output.getType() == types::TY_PP_Asm) - CmdArgs.push_back("--spirv-tools-dis"); + CmdArgs.push_back("-to-text"); CmdArgs.append({"-o", Output.getFilename()}); diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl index eff02f809ce83c..bbb21d91484ffb 100644 --- a/clang/test/Driver/spirv-toolchain.cl +++ b/clang/test/Driver/spirv-toolchain.cl @@ -28,7 +28,7 @@ // SPT64: "-cc1" "-triple" "spirv64" // SPT64-SAME: "-o" [[BC:".*bc"]] -// SPT64: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" {{".*s"}} +// SPT64: {{llvm-spirv.*"}} [[BC]] "-to-text" "-o" {{".*s"}} // RUN: %clang -### --target=spirv32 -x cl -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s // RUN: %clang -### --target=spirv32 -x ir -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s @@ -37,7 +37,7 @@ // SPT32: "-cc1" "-triple" "spirv32" // SPT32-SAME: "-o" [[BC:".*bc"]] -// SPT32: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" {{".*s"}} +// SPT32: {{llvm-spirv.*"}} [[BC]] "-to-text" "-o" {{".*s"}} //----------------------------------------------------------------------------- // Check assembly input -> object output @@ -55,7 +55,7 @@ // TMP: "-cc1" "-triple" "spirv64" // TMP-SAME: "-o" [[BC:".*bc"]] // TMP-SAME: [[I]] -// TMP: {{llvm-spirv.*"}} [[BC]] "--spirv-tools-dis" "-o" [[S:".*s"]] +// TMP: {{llvm-spirv.*"}} [[BC]] "-to-text" "-o" [[S:".*s"]] // TMP: {{llvm-spirv.*"}} [[S]] "-to-binary" "-o" {{".*o"}} //----------------------------------------------------------------------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits