@@ -4384,11 +4384,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
4384
4384
bool IsHIP = JA.isOffloading (Action::OFK_HIP);
4385
4385
bool IsHIPDevice = JA.isDeviceOffloading (Action::OFK_HIP);
4386
4386
bool IsOpenMPDevice = JA.isDeviceOffloading (Action::OFK_OpenMP);
4387
- bool IsOpenMPHost = JA.isHostOffloading (Action::OFK_OpenMP);
4388
4387
bool IsHeaderModulePrecompile = isa<HeaderModulePrecompileJobAction>(JA);
4389
4388
bool IsExtractAPI = isa<ExtractAPIJobAction>(JA);
4390
4389
bool IsDeviceOffloadAction = !(JA.isDeviceOffloading (Action::OFK_None) ||
4391
4390
JA.isDeviceOffloading (Action::OFK_Host));
4391
+ bool IsHostOffloadingAction =
4392
+ JA.isHostOffloading (Action::OFK_OpenMP) &&
4393
+ !Args.hasArg (options::OPT_fno_openmp_new_driver);
4392
4394
bool IsUsingLTO = D.isUsingLTO (IsDeviceOffloadAction);
4393
4395
auto LTOMode = D.getLTOMode (IsDeviceOffloadAction);
4394
4396
@@ -4415,7 +4417,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
4415
4417
4416
4418
InputInfoList ModuleHeaderInputs;
4417
4419
InputInfoList ExtractAPIInputs;
4418
- InputInfoList OpenMPHostInputs ;
4420
+ InputInfoList HostOffloadingInputs ;
4419
4421
const InputInfo *CudaDeviceInput = nullptr ;
4420
4422
const InputInfo *OpenMPDeviceInput = nullptr ;
4421
4423
for (const InputInfo &I : Inputs) {
@@ -4438,12 +4440,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
4438
4440
<< types::getTypeName (ExpectedInputType);
4439
4441
}
4440
4442
ExtractAPIInputs.push_back (I);
4443
+ } else if (IsHostOffloadingAction) {
4444
+ HostOffloadingInputs.push_back (I);
4441
4445
} else if ((IsCuda || IsHIP) && !CudaDeviceInput) {
4442
4446
CudaDeviceInput = &I;
4443
4447
} else if (IsOpenMPDevice && !OpenMPDeviceInput) {
4444
4448
OpenMPDeviceInput = &I;
4445
- } else if (IsOpenMPHost) {
4446
- OpenMPHostInputs.push_back (I);
4447
4449
} else {
4448
4450
llvm_unreachable (" unexpectedly given multiple inputs" );
4449
4451
}
@@ -6948,24 +6950,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
6948
6950
}
6949
6951
}
6950
6952
6951
- // Host-side OpenMP offloading recieves the device object files and embeds it
6952
- // in a named section including the associated target triple and architecture.
6953
- if (IsOpenMPHost && !OpenMPHostInputs.empty ()) {
6954
- auto InputFile = OpenMPHostInputs.begin ();
6955
- auto OpenMPTCs = C.getOffloadToolChains <Action::OFK_OpenMP>();
6956
- for (auto TI = OpenMPTCs.first , TE = OpenMPTCs.second ; TI != TE;
6957
- ++TI, ++InputFile) {
6958
- const ToolChain *TC = TI->second ;
6959
- const ArgList &TCArgs = C.getArgsForToolChain (TC, " " , Action::OFK_OpenMP);
6960
- StringRef File =
6961
- C.getArgs ().MakeArgString (TC->getInputFilename (*InputFile));
6953
+ // Host-side offloading recieves the device object files and embeds it in a
6954
+ // named section including the associated target triple and architecture.
6955
+ for (const InputInfo Input : HostOffloadingInputs) {
6956
+ const Action *OffloadAction = Input.getAction ();
6957
+ const ToolChain *TC = OffloadAction->getOffloadingToolChain ();
6958
+ const ArgList &TCArgs =
6959
+ C.getArgsForToolChain (TC, OffloadAction->getOffloadingArch (),
6960
+ OffloadAction->getOffloadingDeviceKind ());
6961
+ StringRef File = C.getArgs ().MakeArgString (TC->getInputFilename (Input));
6962
+ StringRef Arch = (OffloadAction->getOffloadingArch ())
6963
+ ? OffloadAction->getOffloadingArch ()
6964
+ : TCArgs.getLastArgValue (options::OPT_march_EQ);
6962
6965
6963
- CmdArgs.push_back (
6964
- Args.MakeArgString (" -fembed-offload-object=" + File + " ," +
6965
- Action::GetOffloadKindName (Action::OFK_OpenMP) +
6966
- " ," + TC->getTripleString () + " ," +
6967
- TCArgs.getLastArgValue (options::OPT_march_EQ)));
6968
- }
6966
+ CmdArgs.push_back (Args.MakeArgString (
6967
+ " -fembed-offload-object=" + File + " ," +
6968
+ Action::GetOffloadKindName (OffloadAction->getOffloadingDeviceKind ()) +
6969
+ " ," + TC->getTripleString () + " ," + Arch));
6969
6970
}
6970
6971
6971
6972
if (Triple.isAMDGPU ()) {
0 commit comments