[PATCH] D15936: Update code in buildCudaActions to latest idiom.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 6 13:24:59 PST 2016
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.
Use llvm::make_unique, std::all_of, std::find, etc.
No functional changes.
Prerequisite for further changes to Driver.
http://reviews.llvm.org/D15936
Files:
lib/Driver/Driver.cpp
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<Action>(
- new CudaHostAction(std::move(HostAction), {}));
+ return llvm::make_unique<CudaHostAction>(std::move(HostAction),
+ ActionList());
// Collect all cuda_gpu_arch parameters, removing duplicates.
SmallVector<const char *, 4> 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<Action>(
- new CudaHostAction(std::move(HostAction), DeviceActions));
+ return llvm::make_unique<CudaHostAction>(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<Action> Current(new InputAction(*InputArg, InputType));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15936.44152.patch
Type: text/x-patch
Size: 3186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160106/283d60e7/attachment.bin>
More information about the cfe-commits
mailing list