================
@@ -73,44 +96,97 @@ 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 in the NonSemantic.Shader.DebugInfo form (see the
+ // comment on the equivalent block in the non-chipStar path below).
+ // These flags are passed unconditionally instead of gating on -g: in
+ // RDC-mode links this job runs in a clang invoked by
+ // clang-linker-wrapper where the original -g is not visible, but the
+ // debug info itself travels in the bitcode. The flags only allow
+ // extensions and select the debug info form; with debug-info-free
+ // bitcode the output is unchanged.
----------------
pvelesko wrote:
Right, clarified the comment: SPV_INTEL_optnone is independent of debug info
since clang emits optnone at plain -O0 (76458f3e).
https://github.com/llvm/llvm-project/pull/206910
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits