[OpenMP] Fix `-foffload-lto` for offloading to Nvidia
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 11 Oct 2022 18:39:06 +0000 (13:39 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 11 Oct 2022 18:40:42 +0000 (13:40 -0500)
Summary:
A previous patch ensured that we can't use `-foffload-lto` with CUDA in
non-RDC mode. This did not correctly check for if we were actually
offloading to CUDA so it ended up preventing us from using LTO for
OpenMP.

clang/lib/Driver/ToolChains/Clang.cpp

index 93e0a18..83023a1 100644 (file)
@@ -4851,7 +4851,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                                options::OPT_foffload_lto_EQ)
                    ->getAsString(Args)
             << Triple.getTriple();
-      } else if (Triple.isNVPTX() && !IsRDCMode) {
+      } else if (Triple.isNVPTX() && !IsRDCMode &&
+                 JA.isDeviceOffloading(Action::OFK_Cuda)) {
         D.Diag(diag::err_drv_unsupported_opt_for_language_mode)
             << Args.getLastArg(options::OPT_foffload_lto,
                                options::OPT_foffload_lto_EQ)