================
@@ -73,44 +96,89 @@ void HIPSPV::Linker::constructLinkAndEmitSpirvCommand(
tools::constructLLVMLinkCommand(C, *this, JA, Inputs, LinkArgs, Output, Args,
TempFile);
- // Post-link HIP lowering.
+ auto T = getToolChain().getTriple();
- // Run LLVM IR passes to lower/expand/emulate HIP code that does not
translate
- // to SPIR-V (E.g. dynamic shared memory).
- auto PassPluginPath = findPassPlugin(C.getDriver(), Args);
- if (!PassPluginPath.empty()) {
- const char *PassPathCStr = C.getArgs().MakeArgString(PassPluginPath);
- const char *OptOutput = HIP::getTempFile(C, Name + "-lower", "bc");
- ArgStringList OptArgs{TempFile, "-load-pass-plugin",
- PassPathCStr, "-passes=hip-post-link-passes",
- "-o", OptOutput};
- const char *Opt = Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+ if (T.getOS() == llvm::Triple::ChipStar) {
+ // chipStar: run HipSpvPasses via opt, then emit SPIR-V with the in-tree
+ // SPIR-V backend by default, or with the external llvm-spirv translator
+ // when -fno-integrated-objemitter is given (or the backend is not built).
+
+ // Run HipSpvPasses plugin via opt (must run on LLVM IR before
+ // the SPIR-V backend lowers to MIR).
+ TempFile = runHipSpvPasses(C, JA, *this, getToolChain(), Inputs, Output,
+ Args, Name, TempFile);
+
+ if (!getToolChain().useIntegratedBackend()) {
+ // External translator path: BC -> SPIR-V via llvm-spirv.
+ llvm::opt::ArgStringList TrArgs;
+ if (T.getSubArch() == llvm::Triple::NoSubArch)
+ TrArgs.push_back("--spirv-max-version=1.2");
+ // Keep this extension list in sync with the in-tree backend fallback
+ // below.
+ TrArgs.push_back("--spirv-ext=-all"
+ ",+SPV_INTEL_function_pointers"
+ ",+SPV_INTEL_subgroups"
+ ",+SPV_KHR_bit_instructions"
+ ",+SPV_EXT_shader_atomic_float_add");
+
+ // Preserve debug info requested via -g (see the comment on the
+ // equivalent block in the non-chipStar path below).
+ if (const Arg *A = Args.getLastArg(options::OPT_g_Group);
+ A && !A->getOption().matches(options::OPT_g0)) {
----------------
linehill wrote:
I think, this branch won't be taken when linking object files in RDC-mode - or
you need to specify `-Xoffload-compiler-<SPIR-V triple here> -g` on the link
command.
https://github.com/llvm/llvm-project/pull/206910
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits