[clang] [AMDGPU][SPIR-V] Fix treating SPIR-V input as the wrong LLVM-IR (PR #202986)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 18 07:07:24 PDT 2026


jhuber6 wrote:

> Something like this makes it working:
> 
> ```
> diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> index cfdd11e1d298..37a4a3609323 100644
> --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> @@ -549,7 +549,9 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
>    // the LTO link and defeat the non-LTO pipeline.
>    // FIXME: This is a stop-gap for non-RDC. Longer term, RDC and non-RDC should
>    //        share a unified interface.
> -  if (Args.hasArg(OPT_no_lto))
> 
> +  if (Args.hasArg(OPT_no_lto) && !Triple.isSPIRV())
>      CmdArgs.append({"-x", "ir"});
>    for (StringRef InputFile : InputFiles)
>      CmdArgs.push_back(InputFile);
> @@ -613,7 +615,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
>    for (StringRef Arg : Args.getAllArgValues(OPT_compiler_arg_EQ))
>      CmdArgs.push_back(Args.MakeArgString(Arg));
> 
> -  if (Args.hasArg(OPT_no_lto))
> +  if (Args.hasArg(OPT_no_lto) && !Triple.isSPIRV())
>      CmdArgs.append({"-flto=none", "-Wno-unused-command-line-argument"});
> 
>    if (Error Err = executeCommands(*ClangPath, CmdArgs))
> ```

This makes sense to me, the issue is that we were gating the no-lto on the triple, but it's a global setting right now so it applied to both. This is piling hacks on hacks but could you make a PR for it?

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


More information about the cfe-commits mailing list