aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2022-09-01 17:04:49 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2022-09-06 19:49:47 -0500
commit2753eafe5a7f003776b12f425c5b0a475e8fb6b7 (patch)
treeaef594e8fd10dfa6c9babd0d4ebdf1eb1fd3e889 /clang/lib/Driver/Driver.cpp
parente47ca72e30d16af602e1c40745abed2bde5dbc46 (diff)
downloadllvm-2753eafe5a7f003776b12f425c5b0a475e8fb6b7.zip
llvm-2753eafe5a7f003776b12f425c5b0a475e8fb6b7.tar.gz
llvm-2753eafe5a7f003776b12f425c5b0a475e8fb6b7.tar.bz2
[Clang] Fix the new driver crashing when using '-fsyntax-only'
The new driver currently crashses when attempting to use the '-fsyntax-only' option. This is because the option causes all output to be given the `TY_Nothing' type which should signal the end of the pipeline. The new driver was not treating this correctly and attempting to use empty input. This patch fixes the handling so we do not attempt to continue when the input is nothing. One concession is that we must now check when generating the arguments for Clang if the input is of 'TY_Nothing'. This is because the new driver will only create code if the device code is a dependency on the host, creating the output without the dependency would require a complete rewrite of the logic as we do not maintain any state between calls to 'BuildOffloadingActions' so I believe this is the most straightforward method. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D133161
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 36fba5d..9517331a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4309,10 +4309,14 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
auto TCAndArch = TCAndArchs.begin();
for (Action *&A : DeviceActions) {
+ if (A->getType() == types::TY_Nothing)
+ continue;
+
A = ConstructPhaseAction(C, Args, Phase, A, Kind);
if (isa<CompileJobAction>(A) && isa<CompileJobAction>(HostAction) &&
- Kind == Action::OFK_OpenMP) {
+ Kind == Action::OFK_OpenMP &&
+ HostAction->getType() != types::TY_Nothing) {
// OpenMP offloading has a dependency on the host compile action to
// identify which declarations need to be emitted. This shouldn't be
// collapsed with any other actions so we can use it in the device.
@@ -4380,11 +4384,15 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
nullptr, Action::OFK_None);
}
+ // If we are unable to embed a single device output into the host, we need to
+ // add each device output as a host dependency to ensure they are still built.
+ bool SingleDeviceOutput = !llvm::any_of(OffloadActions, [](Action *A) {
+ return A->getType() == types::TY_Nothing;
+ }) && isa<CompileJobAction>(HostAction);
OffloadAction::HostDependence HDep(
*HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
/*BoundArch=*/nullptr, isa<CompileJobAction>(HostAction) ? DDep : DDeps);
- return C.MakeAction<OffloadAction>(
- HDep, isa<CompileJobAction>(HostAction) ? DDep : DDeps);
+ return C.MakeAction<OffloadAction>(HDep, SingleDeviceOutput ? DDep : DDeps);
}
Action *Driver::ConstructPhaseAction(