Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1291,18 +1291,19 @@ // Host-only compilation case. if (PartialCompilationArg && PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only)) - return std::unique_ptr( - new CudaHostAction(std::move(HostAction), {})); + return llvm::make_unique(std::move(HostAction), + ActionList()); // Collect all cuda_gpu_arch parameters, removing duplicates. SmallVector GpuArchList; llvm::StringSet<> GpuArchNames; for (Arg *A : Args) { - if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) { - A->claim(); - if (GpuArchNames.insert(A->getValue()).second) - GpuArchList.push_back(A->getValue()); + if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) { + continue; } + A->claim(); + if (GpuArchNames.insert(A->getValue()).second) + GpuArchList.push_back(A->getValue()); } // Default to sm_20 which is the lowest common denominator for supported GPUs. @@ -1325,13 +1326,9 @@ "Failed to create actions for all devices"); // Check whether any of device actions stopped before they could generate PTX. - bool PartialCompilation = false; - for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) { - if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) { - PartialCompilation = true; - break; - } - } + bool PartialCompilation = std::any_of( + CudaDeviceActions.begin(), CudaDeviceActions.end(), + [](const Action *a) { return a->getKind() != Action::BackendJobClass; }); // Figure out what to do with device actions -- pass them as inputs to the // host action or run each of them independently. @@ -1355,7 +1352,7 @@ /* AtTopLevel */ true)); // Kill host action in case of device-only compilation. if (DeviceOnlyCompilation) - HostAction.reset(nullptr); + HostAction.reset(); return HostAction; } @@ -1368,8 +1365,8 @@ /* AtTopLevel */ false)); // Return a new host action that incorporates original host action and all // device actions. - return std::unique_ptr( - new CudaHostAction(std::move(HostAction), DeviceActions)); + return llvm::make_unique(std::move(HostAction), + DeviceActions); } void Driver::BuildActions(Compilation &C, const ToolChain &TC, @@ -1470,12 +1467,11 @@ continue; } - phases::ID CudaInjectionPhase = FinalPhase; - for (const auto &Phase : PL) - if (Phase <= FinalPhase && Phase == phases::Compile) { - CudaInjectionPhase = Phase; - break; - } + phases::ID CudaInjectionPhase = + (phases::Compile < FinalPhase && + std::find(PL.begin(), PL.end(), phases::Compile) != PL.end()) + ? phases::Compile + : FinalPhase; // Build the pipeline for this file. std::unique_ptr Current(new InputAction(*InputArg, InputType));