[PATCH] D123325: [Clang] Make enabling the new driver more generic
Joseph Huber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 18 15:29:01 PDT 2022
jhuber6 updated this revision to Diff 423479.
jhuber6 added a comment.
Fix
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123325/new/
https://reviews.llvm.org/D123325
Files:
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4381,8 +4381,9 @@
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.hasArg(options::OPT_fno_openmp_new_driver)) ||
+ Args.hasArg(options::OPT_foffload_new_driver);
bool IsUsingLTO = D.isUsingLTO(IsDeviceOffloadAction);
auto LTOMode = D.getLTOMode(IsDeviceOffloadAction);
@@ -4674,6 +4675,7 @@
// Only AMDGPU supports device-side LTO.
if (IsDeviceOffloadAction &&
Args.hasArg(options::OPT_fno_openmp_new_driver) &&
+ !Args.hasArg(options::OPT_foffload_new_driver) &&
!Triple.isAMDGPU()) {
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< Args.getLastArg(options::OPT_foffload_lto,
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3891,16 +3891,17 @@
// Builder to be used to build offloading actions.
OffloadingActionBuilder OffloadBuilder(C, Args, Inputs);
+ bool UseNewOffloadingDriver =
+ (C.isOffloadingHostKind(Action::OFK_OpenMP) &&
+ !Args.hasArg(options::OPT_fno_openmp_new_driver)) ||
+ Args.hasArg(options::OPT_foffload_new_driver);
+
// Construct the actions to perform.
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr;
ExtractAPIJobAction *ExtractAPIAction = nullptr;
ActionList LinkerInputs;
ActionList MergerInputs;
- bool UseNewOffloadingDriver =
- C.isOffloadingHostKind(Action::OFK_OpenMP) &&
- !Args.hasArg(options::OPT_fno_openmp_new_driver);
-
for (auto &I : Inputs) {
types::ID InputType = I.first;
const Arg *InputArg = I.second;
@@ -4024,8 +4025,7 @@
// 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);
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2523,6 +2523,8 @@
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.">;
+def foffload_new_driver : Flag<["-"], "foffload-new-driver">, Flags<[CC1Option]>, Group<Action_Group>,
+ HelpText<"Use the new driver for 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">>;
Index: clang/include/clang/Driver/Compilation.h
===================================================================
--- clang/include/clang/Driver/Compilation.h
+++ clang/include/clang/Driver/Compilation.h
@@ -139,7 +139,7 @@
const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
- unsigned isOffloadingHostKind(Action::OffloadKind Kind) const {
+ unsigned isOffloadingHostKind(unsigned int Kind) const {
return ActiveOffloadMask & Kind;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123325.423479.patch
Type: text/x-patch
Size: 4034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220418/9addf90c/attachment-0001.bin>
More information about the cfe-commits
mailing list