@@ -10263,8 +10263,18 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1026310263 const InputInfo &I = Inputs[0 ];
1026410264 assert (I.isFilename () && " Invalid input." );
1026510265
10266- if (I.getType () == types::TY_Tempfiletable ||
10267- I.getType () == types::TY_Tempfilelist || IsEmbeddedIR)
10266+ // TODO: The embedded compilation step after the wrapping step restricts
10267+ // the ability to control the 'for each' methodology used when performing
10268+ // device code splitting. We set the individual wrap behavior when we know
10269+ // the wrapping and compile step should be done individually. Ideally this
10270+ // would be controlled at the JobAction creation, but we cannot do that
10271+ // until the compilation of the wrap is it's own JobAction.
10272+ bool IndividualWrapCompile = WrapperJob.getWrapIndividualFiles ();
10273+ const InputInfo TempOutput (types::TY_LLVM_BC, WrapperFileName,
10274+ WrapperFileName);
10275+ if (!IndividualWrapCompile &&
10276+ (I.getType () == types::TY_Tempfiletable ||
10277+ I.getType () == types::TY_Tempfilelist || IsEmbeddedIR))
1026810278 // Input files are passed via the batch job file table.
1026910279 WrapperArgs.push_back (C.getArgs ().MakeArgString (" -batch" ));
1027010280 WrapperArgs.push_back (C.getArgs ().MakeArgString (I.getFilename ()));
@@ -10273,7 +10283,17 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1027310283 JA, *this , ResponseFileSupport::None (),
1027410284 TCArgs.MakeArgString (getToolChain ().GetProgramPath (getShortName ())),
1027510285 WrapperArgs, std::nullopt );
10276- C.addCommand (std::move (Cmd));
10286+
10287+ if (IndividualWrapCompile) {
10288+ // When wrapping FPGA device binaries for FPGA archives, create individual
10289+ // wrapped and compiled entries for the archive.
10290+ StringRef ParallelJobs =
10291+ C.getArgs ().getLastArgValue (options::OPT_fsycl_max_parallel_jobs_EQ);
10292+ clang::driver::tools::SYCL::constructLLVMForeachCommand (
10293+ C, JA, std::move (Cmd), Inputs, TempOutput, this , " " , " bc" ,
10294+ ParallelJobs);
10295+ } else
10296+ C.addCommand (std::move (Cmd));
1027710297
1027810298 if (WrapperCompileEnabled) {
1027910299 // TODO Use TC.SelectTool().
@@ -10296,9 +10316,19 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1029610316 SmallString<128 > ClangPath (C.getDriver ().Dir );
1029710317 llvm::sys::path::append (ClangPath, " clang" );
1029810318 const char *Clang = C.getArgs ().MakeArgString (ClangPath);
10299- C.addCommand (std::make_unique<Command>(JA, *this ,
10300- ResponseFileSupport::None (), Clang,
10301- ClangArgs, std::nullopt ));
10319+ auto PostWrapCompileCmd =
10320+ std::make_unique<Command>(JA, *this , ResponseFileSupport::None (),
10321+ Clang, ClangArgs, std::nullopt );
10322+ if (IndividualWrapCompile) {
10323+ StringRef ParallelJobs = C.getArgs ().getLastArgValue (
10324+ options::OPT_fsycl_max_parallel_jobs_EQ);
10325+ InputInfoList Inputs;
10326+ Inputs.push_back (TempOutput);
10327+ clang::driver::tools::SYCL::constructLLVMForeachCommand (
10328+ C, JA, std::move (PostWrapCompileCmd), Inputs, Output, this , " " ,
10329+ " bc" , ParallelJobs);
10330+ } else
10331+ C.addCommand (std::move (PostWrapCompileCmd));
1030210332 }
1030310333 return ;
1030410334 } // end of SYCL flavor of offload wrapper command creation
0 commit comments