aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2022-07-15 13:52:27 -0400
committerJoseph Huber <jhuber6@vols.utk.edu>2022-07-15 17:38:34 -0400
commitbb957a8d524cd38d6c5f7d547302258026049438 (patch)
tree0b5e8998af8eef21fc71075cd78d36fd5a401e1f /clang/lib
parentf32ccc2cca1df39e0f5b5aac0ec30d490104b58c (diff)
downloadllvm-bb957a8d524cd38d6c5f7d547302258026049438.zip
llvm-bb957a8d524cd38d6c5f7d547302258026049438.tar.gz
llvm-bb957a8d524cd38d6c5f7d547302258026049438.tar.bz2
[CUDA] Make the new driver properly ignore non-CUDA inputs
The new driver generated offloadinga actions for each active toolchain. However, for CUDA and HIP it is possible for the toolchain to be active but one of the files is not a valid input. This can occur if the user compiles both a CUDA and C source file in the same compiler invocation. This patch adds some simple logic to quit if the input is not valid as well. Reviewed By: tra, MaskRay Differential Revision: https://reviews.llvm.org/D129885
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Driver.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3a8400a..bd2b9a5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4432,6 +4432,11 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
types::ID InputType = Input.first;
const Arg *InputArg = Input.second;
+ // The toolchain can be active for unsupported file types.
+ if ((Kind == Action::OFK_Cuda && !types::isCuda(InputType)) ||
+ (Kind == Action::OFK_HIP && !types::isHIP(InputType)))
+ continue;
+
// Get the product of all bound architectures and toolchains.
SmallVector<std::pair<const ToolChain *, StringRef>> TCAndArchs;
for (const ToolChain *TC : ToolChains)
@@ -4486,6 +4491,9 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
if (offloadDeviceOnly())
return C.MakeAction<OffloadAction>(DDeps, types::TY_Nothing);
+ if (OffloadActions.empty())
+ return HostAction;
+
OffloadAction::DeviceDependences DDep;
if (C.isOffloadingHostKind(Action::OFK_Cuda) &&
!Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false)) {