summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-04-19 02:27:07 +0000
committerJustin Lebar <jlebar@google.com>2016-04-19 02:27:07 +0000
commitdc3c50434ec5f183b60d4b71e08d39f326093b89 (patch)
treeaca8e707a4b4f9b5fc93d08ab5fa4c5c85fce9aa /clang/lib/Driver/Driver.cpp
parentd66dc19251d0304dd159d8f013760e852db50bbd (diff)
downloadbcm5719-llvm-dc3c50434ec5f183b60d4b71e08d39f326093b89.tar.gz
bcm5719-llvm-dc3c50434ec5f183b60d4b71e08d39f326093b89.zip
[CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.
Summary: This completes the flag's tristate, letting you override it at will on the command line. Reviewers: tra Subscribers: cfe-commits, jhen Differential Revision: http://reviews.llvm.org/D19248 llvm-svn: 266707
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 989432320c5..74121ecf51d 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1316,11 +1316,17 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
const Arg *InputArg, Action *HostAction,
ActionList &Actions) {
- Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
- options::OPT_cuda_device_only);
- // Host-only compilation case.
- if (PartialCompilationArg &&
- PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
+ Arg *PartialCompilationArg = Args.getLastArg(
+ options::OPT_cuda_host_only, options::OPT_cuda_device_only,
+ options::OPT_cuda_compile_host_device);
+ bool CompileHostOnly =
+ PartialCompilationArg &&
+ PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only);
+ bool CompileDeviceOnly =
+ PartialCompilationArg &&
+ PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only);
+
+ if (CompileHostOnly)
return C.MakeAction<CudaHostAction>(HostAction, ActionList());
// Collect all cuda_gpu_arch parameters, removing duplicates.
@@ -1364,15 +1370,14 @@ static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
// Figure out what to do with device actions -- pass them as inputs to the
// host action or run each of them independently.
- bool DeviceOnlyCompilation = PartialCompilationArg != nullptr;
- if (PartialCompilation || DeviceOnlyCompilation) {
+ if (PartialCompilation || CompileDeviceOnly) {
// In case of partial or device-only compilation results of device actions
// are not consumed by the host action device actions have to be added to
// top-level actions list with AtTopLevel=true and run independently.
// -o is ambiguous if we have more than one top-level action.
if (Args.hasArg(options::OPT_o) &&
- (!DeviceOnlyCompilation || GpuArchList.size() > 1)) {
+ (!CompileDeviceOnly || GpuArchList.size() > 1)) {
C.getDriver().Diag(
clang::diag::err_drv_output_argument_with_multiple_files);
return nullptr;
@@ -1383,7 +1388,7 @@ static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
GpuArchList[I],
/* AtTopLevel */ true));
// Kill host action in case of device-only compilation.
- if (DeviceOnlyCompilation)
+ if (CompileDeviceOnly)
return nullptr;
return HostAction;
}
@@ -1647,9 +1652,10 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
// Claim ignored clang-cl options.
Args.ClaimAllArgs(options::OPT_cl_ignored_Group);
- // Claim --cuda-host-only arg which may be passed to non-CUDA
- // compilations and should not trigger warnings there.
+ // Claim --cuda-host-only and --cuda-compile-host-device, which may be passed
+ // to non-CUDA compilations and should not trigger warnings there.
Args.ClaimAllArgs(options::OPT_cuda_host_only);
+ Args.ClaimAllArgs(options::OPT_cuda_compile_host_device);
}
Action *Driver::ConstructPhaseAction(Compilation &C, const ArgList &Args,
OpenPOWER on IntegriCloud