diff options
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 14 |
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( |