forked from OSchip/llvm-project
[Clang] Make enabling the new driver more generic
In preparation for allowing other offloading kinds to use the new driver a new opt-in flag `-foffload-new-driver` is added. This is distinct from the existing `-fopenmp-new-driver` because OpenMP will soon use the new driver by default while the others should not. Reviewed By: yaxunl, tra Differential Revision: https://reviews.llvm.org/D123325
This commit is contained in:
parent
ca6bbe0085
commit
4e2b5a6693
|
@ -2534,10 +2534,14 @@ defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
|
|||
PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[NoArgumentUnused, HelpHidden]>>;
|
||||
def static_openmp: Flag<["-"], "static-openmp">,
|
||||
HelpText<"Use the static host OpenMP runtime while linking.">;
|
||||
def offload_new_driver : Flag<["--"], "offload-new-driver">, Flags<[CC1Option]>, Group<Action_Group>,
|
||||
HelpText<"Use the new driver for offloading compilation.">;
|
||||
def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, Flags<[CC1Option]>, Group<Action_Group>,
|
||||
HelpText<"Don't Use the new driver for offloading compilation.">;
|
||||
def fopenmp_new_driver : Flag<["-"], "fopenmp-new-driver">, Flags<[CC1Option]>, Group<Action_Group>,
|
||||
HelpText<"Use the new driver for OpenMP offloading.">;
|
||||
def fno_openmp_new_driver : Flag<["-"], "fno-openmp-new-driver">, Flags<[CC1Option]>, Group<Action_Group>,
|
||||
HelpText<"Don't use the new driver for OpenMP offloading.">;
|
||||
Alias<no_offload_new_driver>, HelpText<"Don't use the new driver for OpenMP offloading.">;
|
||||
def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group<f_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Disable tail call optimization, keeping the call stack accurate">,
|
||||
MarshallingInfoFlag<CodeGenOpts<"DisableTailCalls">>;
|
||||
|
|
|
@ -3976,17 +3976,19 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
|
|||
// Builder to be used to build offloading actions.
|
||||
OffloadingActionBuilder OffloadBuilder(C, Args, Inputs);
|
||||
|
||||
bool UseNewOffloadingDriver =
|
||||
(C.isOffloadingHostKind(Action::OFK_OpenMP) &&
|
||||
Args.hasFlag(options::OPT_fopenmp_new_driver,
|
||||
options::OPT_no_offload_new_driver, true)) ||
|
||||
Args.hasFlag(options::OPT_offload_new_driver,
|
||||
options::OPT_no_offload_new_driver, false);
|
||||
|
||||
// Construct the actions to perform.
|
||||
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr;
|
||||
ExtractAPIJobAction *ExtractAPIAction = nullptr;
|
||||
ActionList LinkerInputs;
|
||||
ActionList MergerInputs;
|
||||
|
||||
bool UseNewOffloadingDriver =
|
||||
C.isOffloadingHostKind(Action::OFK_OpenMP) &&
|
||||
Args.hasFlag(options::OPT_fopenmp_new_driver,
|
||||
options::OPT_fno_openmp_new_driver, true);
|
||||
|
||||
for (auto &I : Inputs) {
|
||||
types::ID InputType = I.first;
|
||||
const Arg *InputArg = I.second;
|
||||
|
@ -4114,8 +4116,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
|
|||
// Check if this Linker Job should emit a static library.
|
||||
if (ShouldEmitStaticLibrary(Args)) {
|
||||
LA = C.MakeAction<StaticLibJobAction>(LinkerInputs, types::TY_Image);
|
||||
} else if (UseNewOffloadingDriver &&
|
||||
C.getActiveOffloadKinds() != Action::OFK_None) {
|
||||
} else if (UseNewOffloadingDriver) {
|
||||
LA = C.MakeAction<LinkerWrapperJobAction>(LinkerInputs, types::TY_Image);
|
||||
LA->propagateHostOffloadInfo(C.getActiveOffloadKinds(),
|
||||
/*BoundArch=*/nullptr);
|
||||
|
|
|
@ -4389,8 +4389,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
bool IsDeviceOffloadAction = !(JA.isDeviceOffloading(Action::OFK_None) ||
|
||||
JA.isDeviceOffloading(Action::OFK_Host));
|
||||
bool IsHostOffloadingAction =
|
||||
JA.isHostOffloading(Action::OFK_OpenMP) &&
|
||||
!Args.hasArg(options::OPT_fno_openmp_new_driver);
|
||||
(JA.isHostOffloading(Action::OFK_OpenMP) &&
|
||||
Args.hasFlag(options::OPT_fopenmp_new_driver,
|
||||
options::OPT_no_offload_new_driver, true)) ||
|
||||
Args.hasFlag(options::OPT_offload_new_driver,
|
||||
options::OPT_no_offload_new_driver, false);
|
||||
bool IsUsingLTO = D.isUsingLTO(IsDeviceOffloadAction);
|
||||
auto LTOMode = D.getLTOMode(IsDeviceOffloadAction);
|
||||
|
||||
|
@ -4686,7 +4689,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
// Only AMDGPU supports device-side LTO.
|
||||
if (IsDeviceOffloadAction &&
|
||||
!Args.hasFlag(options::OPT_fopenmp_new_driver,
|
||||
options::OPT_fno_openmp_new_driver, true) &&
|
||||
options::OPT_no_offload_new_driver, true) &&
|
||||
!Args.hasFlag(options::OPT_offload_new_driver,
|
||||
options::OPT_no_offload_new_driver, false) &&
|
||||
!Triple.isAMDGPU()) {
|
||||
D.Diag(diag::err_drv_unsupported_opt_for_target)
|
||||
<< Args.getLastArg(options::OPT_foffload_lto,
|
||||
|
|
Loading…
Reference in New Issue