@@ -5024,24 +5024,15 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
50245024 // Compiling HIP in device-only non-RDC mode requires linking each action
50255025 // individually.
50265026 for (Action *&A : DeviceActions) {
5027+ // Special handling for the HIP SPIR-V toolchain because it doesn't use
5028+ // the SPIR-V backend yet doesn't report the output as an object.
50275029 bool IsAMDGCNSPIRV = A->getOffloadingToolChain () &&
50285030 A->getOffloadingToolChain ()->getTriple ().getOS () ==
50295031 llvm::Triple::OSType::AMDHSA &&
50305032 A->getOffloadingToolChain ()->getTriple ().isSPIRV ();
5031- bool UseSPIRVBackend = Args.hasFlag (options::OPT_use_spirv_backend,
5032- options::OPT_no_use_spirv_backend,
5033- /* Default=*/ false );
5034-
5035- // Special handling for the HIP SPIR-V toolchain in device-only.
5036- // The translator path has a linking step, whereas the SPIR-V backend path
5037- // does not to avoid any external dependency such as spirv-link. The
5038- // linking step is skipped for the SPIR-V backend path.
5039- bool IsAMDGCNSPIRVWithBackend = IsAMDGCNSPIRV && UseSPIRVBackend;
5040-
50415033 if ((A->getType () != types::TY_Object && !IsAMDGCNSPIRV &&
50425034 A->getType () != types::TY_LTO_BC) ||
5043- HIPRelocatableObj || !HIPNoRDC || !offloadDeviceOnly () ||
5044- (IsAMDGCNSPIRVWithBackend && offloadDeviceOnly ()))
5035+ HIPRelocatableObj || !HIPNoRDC || !offloadDeviceOnly ())
50455036 continue ;
50465037 ActionList LinkerInput = {A};
50475038 A = C.MakeAction <LinkJobAction>(LinkerInput, types::TY_Image);
@@ -5267,28 +5258,12 @@ Action *Driver::ConstructPhaseAction(
52675258 Args.hasArg (options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
52685259 return C.MakeAction <BackendJobAction>(Input, Output);
52695260 }
5270- bool UseSPIRVBackend = Args.hasFlag (options::OPT_use_spirv_backend,
5271- options::OPT_no_use_spirv_backend,
5272- /* Default=*/ false );
5273-
5274- auto OffloadingToolChain = Input->getOffloadingToolChain ();
5275- // For AMD SPIRV, if offloadDeviceOnly(), we call the SPIRV backend unless
5276- // LLVM bitcode was requested explicitly or RDC is set. If
5277- // !offloadDeviceOnly, we emit LLVM bitcode, and clang-linker-wrapper will
5278- // compile it to SPIRV.
5279- bool UseSPIRVBackendForHipDeviceOnlyNoRDC =
5280- TargetDeviceOffloadKind == Action::OFK_HIP && OffloadingToolChain &&
5281- OffloadingToolChain->getTriple ().isSPIRV () && UseSPIRVBackend &&
5282- offloadDeviceOnly () &&
5283- !Args.hasFlag (options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false );
5284-
52855261 if (Args.hasArg (options::OPT_emit_llvm) ||
52865262 TargetDeviceOffloadKind == Action::OFK_SYCL ||
52875263 (((Input->getOffloadingToolChain () &&
52885264 Input->getOffloadingToolChain ()->getTriple ().isAMDGPU () &&
52895265 TargetDeviceOffloadKind != Action::OFK_None) ||
52905266 TargetDeviceOffloadKind == Action::OFK_HIP) &&
5291- !UseSPIRVBackendForHipDeviceOnlyNoRDC &&
52925267 ((Args.hasFlag (options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
52935268 false ) ||
52945269 (Args.hasFlag (options::OPT_offload_new_driver,
@@ -5310,19 +5285,6 @@ Action *Driver::ConstructPhaseAction(
53105285 : types::TY_LLVM_BC;
53115286 return C.MakeAction <BackendJobAction>(Input, Output);
53125287 }
5313-
5314- // The SPIRV backend compilation path for HIP must avoid external
5315- // dependencies. The default compilation path assembles and links its
5316- // output, but the SPIRV assembler and linker are external tools. This code
5317- // ensures the backend emits binary SPIRV directly to bypass those steps and
5318- // avoid failures. Without -save-temps, the compiler may already skip
5319- // assembling and linking. With -save-temps, these steps must be explicitly
5320- // disabled, as done here. We also force skipping these steps regardless of
5321- // -save-temps to avoid relying on optimizations (unless -S is set).
5322- // The current HIP bundling expects the type to be types::TY_Image
5323- if (UseSPIRVBackendForHipDeviceOnlyNoRDC && !Args.hasArg (options::OPT_S))
5324- return C.MakeAction <BackendJobAction>(Input, types::TY_Image);
5325-
53265288 return C.MakeAction <BackendJobAction>(Input, types::TY_PP_Asm);
53275289 }
53285290 case phases::Assemble:
0 commit comments