[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 13:13:56 PDT 2022


jhuber6 updated this revision to Diff 423459.
jhuber6 added a comment.

Rebase & update after making the new driver default for OpenMP.


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
@@ -4382,7 +4382,8 @@
                                  JA.isDeviceOffloading(Action::OFK_Host));
   bool IsHostOffloadingAction =
       JA.isHostOffloading(C.getActiveOffloadKinds()) &&
-      Args.hasArg(options::OPT_fopenmp_new_driver);
+      (Args.hasArg(options::OPT_fopenmp_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
@@ -3897,9 +3897,12 @@
   ActionList LinkerInputs;
   ActionList MergerInputs;
 
+  // We should use the new offloading driver for OpenMP offloading unless
+  // explicitly disabled.
   bool UseNewOffloadingDriver =
-      C.isOffloadingHostKind(Action::OFK_OpenMP) &&
-      !Args.hasArg(options::OPT_fno_openmp_new_driver);
+      (C.isOffloadingHostKind(Action::OFK_OpenMP) &&
+       !Args.hasArg(options::OPT_fno_openmp_new_driver)) ||
+      Args.hasArg(options::OPT_foffload_new_driver);
 
   for (auto &I : Inputs) {
     types::ID InputType = I.first;
@@ -4024,8 +4027,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.423459.patch
Type: text/x-patch
Size: 3662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220418/ac90466f/attachment-0001.bin>


More information about the cfe-commits mailing list