summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2016-08-02 22:37:47 +0000
committerArtem Belevich <tra@google.com>2016-08-02 22:37:47 +0000
commitf981e30b45a88dda761100909940167648db42e6 (patch)
treece3e52bf7584d7c143356dde0f2bb4c894f94b9b /clang/lib/Driver/Driver.cpp
parent707894b09270dc072f734d2a28567db58bc36b34 (diff)
downloadbcm5719-llvm-f981e30b45a88dda761100909940167648db42e6.tar.gz
bcm5719-llvm-f981e30b45a88dda761100909940167648db42e6.zip
[CUDA] Do not allow using NVPTX target for host compilation.
Differential Revision: https://reviews.llvm.org/D23042 llvm-svn: 277537
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 43ec2164a48..db7825adc58 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1407,11 +1407,19 @@ static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
bool CompileDeviceOnly =
PartialCompilationArg &&
PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only);
+ const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
+ assert(HostTC && "No toolchain for host compilation.");
+ if (HostTC->getTriple().isNVPTX()) {
+ // We do not support targeting NVPTX for host compilation. Throw
+ // an error and abort pipeline construction early so we don't trip
+ // asserts that assume device-side compilation.
+ C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);
+ return nullptr;
+ }
if (CompileHostOnly) {
- OffloadAction::HostDependence HDep(
- *HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
- /*BoundArch=*/nullptr, Action::OFK_Cuda);
+ OffloadAction::HostDependence HDep(*HostAction, *HostTC,
+ /*BoundArch=*/nullptr, Action::OFK_Cuda);
return C.MakeAction<OffloadAction>(HDep);
}
@@ -1507,9 +1515,8 @@ static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
// Return a new host action that incorporates original host action and all
// device actions.
- OffloadAction::HostDependence HDep(
- *HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
- /*BoundArch=*/nullptr, Action::OFK_Cuda);
+ OffloadAction::HostDependence HDep(*HostAction, *HostTC,
+ /*BoundArch=*/nullptr, Action::OFK_Cuda);
OffloadAction::DeviceDependences DDep;
DDep.add(*FatbinAction, *CudaTC, /*BoundArch=*/nullptr, Action::OFK_Cuda);
return C.MakeAction<OffloadAction>(HDep, DDep);
OpenPOWER on IntegriCloud