@@ -6350,7 +6350,7 @@ class OffloadingActionBuilder final {
63506350 if (GpuInitHasErrors)
63516351 return true ;
63526352
6353- int I = 0 ;
6353+ int GenIndex = 0 ;
63546354 // Fill SYCLTargetInfoList
63556355 for (auto &TT : SYCLTripleList) {
63566356 auto TCIt = llvm::find_if (
@@ -6363,10 +6363,21 @@ class OffloadingActionBuilder final {
63636363 // is the target device.
63646364 if (TT.isSPIR () &&
63656365 TT.getSubArch () == llvm::Triple::SPIRSubArch_gen) {
6366- StringRef Device (GpuArchList[I].second );
6366+ // Multiple spir64_gen targets are allowed to be used via the
6367+ // -fsycl-targets=spir64_gen and -fsycl-targets=intel_gpu_*
6368+ // specifiers. Using an index through the known GpuArchList
6369+ // values, increment through them accordingly to allow for
6370+ // the multiple settings as well as preventing re-use.
6371+ while (TT != GpuArchList[GenIndex].first &&
6372+ GenIndex < GpuArchList.size ())
6373+ ++GenIndex;
6374+ if (GpuArchList[GenIndex].first != TT)
6375+ // No match.
6376+ continue ;
6377+ StringRef Device (GpuArchList[GenIndex].second );
63676378 SYCLTargetInfoList.emplace_back (
63686379 *TCIt, Device.empty () ? nullptr : Device.data ());
6369- ++I ;
6380+ ++GenIndex ;
63706381 continue ;
63716382 }
63726383 SYCLTargetInfoList.emplace_back (*TCIt, nullptr );
@@ -6380,7 +6391,6 @@ class OffloadingActionBuilder final {
63806391 }
63816392 assert (OffloadArch && " Failed to find matching arch." );
63826393 SYCLTargetInfoList.emplace_back (*TCIt, OffloadArch);
6383- ++I;
63846394 }
63856395 }
63866396 }
@@ -6776,13 +6786,10 @@ class OffloadingActionBuilder final {
67766786 // Do not use unbundler if the Host does not depend on device action.
67776787 // Now that we have unbundled the object, when doing -fsycl-link we
67786788 // want to continue the host link with the input object.
6779- // For unbundling of an FPGA AOCX binary, we want to link with the original
6780- // FPGA device archive.
67816789 if ((OffloadKind == Action::OFK_None && CanUseBundler) ||
67826790 (Args.hasArg (options::OPT_fsycl_link_EQ) && !HasFPGATarget) ||
67836791 (HasFPGATarget && ((Args.hasArg (options::OPT_fsycl_link_EQ) &&
6784- HostAction->getType () == types::TY_Object) ||
6785- HostAction->getType () == types::TY_FPGA_AOCX)))
6792+ HostAction->getType () == types::TY_Object))))
67866793 if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction))
67876794 HostAction = UA->getInputs ().back ();
67886795
@@ -7433,14 +7440,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
74337440
74347441 // For an FPGA archive, we add the unbundling step above to take care of
74357442 // the device side, but also unbundle here to extract the host side
7436- bool EarlyLink = false ;
7437- if (const Arg *A = Args.getLastArg (options::OPT_fsycl_link_EQ))
7438- EarlyLink = A->getValue () == StringRef (" early" );
74397443 for (auto &LI : LinkerInputs) {
74407444 Action *UnbundlerInput = nullptr ;
74417445 auto wrapObject = [&] {
7442- if (EarlyLink && Args.hasArg (options::OPT_fintelfpga)) {
7443- // Only wrap the object with -fsycl-link=early
7446+ if (Args.hasArg (options::OPT_fsycl_link_EQ) &&
7447+ Args.hasArg (options::OPT_fintelfpga)) {
7448+ // Wrap the object when creating an FPGA AOCX or AOCR binary.
74447449 auto *BC = C.MakeAction <OffloadWrapperJobAction>(LI, types::TY_LLVM_BC);
74457450 auto *ASM = C.MakeAction <BackendJobAction>(BC, types::TY_PP_Asm);
74467451 auto *OBJ = C.MakeAction <AssembleJobAction>(ASM, types::TY_Object);
0 commit comments