[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

Manuel Carrasco via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 16 03:05:12 PDT 2025


================
@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
 
   constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
 
-  // Emit SPIR-V binary.
-  llvm::opt::ArgStringList TrArgs{
-      "--spirv-max-version=1.6",
-      "--spirv-ext=+all",
-      "--spirv-allow-unknown-intrinsics",
-      "--spirv-lower-const-expr",
-      "--spirv-preserve-auxdata",
-      "--spirv-debug-info-version=nonsemantic-shader-200"};
-  SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
+  bool UseSPIRVBackend = Args.hasFlag(
+      options::OPT_use_experimental_spirv_backend,
+      options::OPT_no_use_experimental_spirv_backend, /*Default=*/false);
+
+  // Emit SPIR-V binary either using the SPIRV backend or the translator.
+  if (UseSPIRVBackend) {
+    llvm::opt::ArgStringList CmdArgs;
+    const char *Triple =
+        C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
+    CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),
----------------
mgcarrasco wrote:

The PR now emits SPIRV directly when using the backend and this extra call to clang -cc1 is no longer required.

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


More information about the cfe-commits mailing list