From 5a8a262055f56a6bb896e2f5616233beac2d2673 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Thu, 15 Sep 2016 23:44:13 +0000 Subject: [PATCH] [CUDA] Don't try to run sanitizers on NVPTX. Summary: Sanitizers aren't supported on NVPTX -- don't try to run them. This lets you e.g. pass -fsanitize=address and get asan on your host code. Reviewers: kcc Subscribers: cfe-commits, tra, jhen Differential Revision: https://reviews.llvm.org/D24640 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281680 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/SanitizerArgs.cpp | 6 ++++++ test/Driver/cuda-no-sanitizers.cu | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/Driver/cuda-no-sanitizers.cu diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp index 8ba8e53e00..7f1f6715fd 100644 --- a/lib/Driver/SanitizerArgs.cpp +++ b/lib/Driver/SanitizerArgs.cpp @@ -608,6 +608,12 @@ static void addIncludeLinkerOption(const ToolChain &TC, void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const { + // NVPTX doesn't currently support sanitizers. Bailing out here means that + // e.g. -fsanitize=address applies only to host code, which is what we want + // for now. + if (TC.getTriple().isNVPTX()) + return; + // Translate available CoverageFeatures to corresponding clang-cc1 flags. // Do it even if Sanitizers.empty() since some forms of coverage don't require // sanitizers. diff --git a/test/Driver/cuda-no-sanitizers.cu b/test/Driver/cuda-no-sanitizers.cu new file mode 100644 index 0000000000..e344f9043a --- /dev/null +++ b/test/Driver/cuda-no-sanitizers.cu @@ -0,0 +1,12 @@ +// Check that -fsanitize=foo doesn't get passed down to device-side +// compilation. +// +// REQUIRES: clang-driver +// +// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ +// RUN: FileCheck %s + +// CHECK-DAG: "-fcuda-is-device" +// CHECK-NOT: "-fsanitize=address" +// CHECK-DAG: "-triple" "x86_64--linux-gnu" +// CHECK: "-fsanitize=address" -- 2.40.0