[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX
jhen created this revision. jhen added a reviewer: jlebar. jhen added a subscriber: cfe-commits. This adds to the work from https://reviews.llvm.org/rL281680. This patch takes care of another execution path in which sanitizer arguments can be considered for NVPTX because they are used for the corresponding host code. https://reviews.llvm.org/D27316 Files: lib/Driver/SanitizerArgs.cpp Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -206,6 +206,12 @@ for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend(); I != E; ++I) { +// NVPTX doesn't currently support sanitizers, but sanitizer arguments can +// still appear on the command line for host code. This means that we must +// explicitly ignore sanitizer flags here for device code compilation. +if (TC.getTriple().isNVPTX()) { + break; +} const auto *Arg = *I; if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) { Arg->claim(); Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -206,6 +206,12 @@ for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend(); I != E; ++I) { +// NVPTX doesn't currently support sanitizers, but sanitizer arguments can +// still appear on the command line for host code. This means that we must +// explicitly ignore sanitizer flags here for device code compilation. +if (TC.getTriple().isNVPTX()) { + break; +} const auto *Arg = *I; if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) { Arg->claim(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX
jhen added a reviewer: kcc. jhen added a comment. Before this patch, the following command would fail: clang++ -fsanitize=address --cuda-gpu-arch=sm_20 -c example.cu with error: clang-4.0: error: unsupported option '-fsanitize=address' for target 'nvptx64-nvidia-cuda' After this patch, there is no such compilation error. I don't understand this part of the driver code very well, so I would appreciate any advice on whether this is the right way to fix this bug, and where would be the right place for me to put a test to check that it is working (i.e. ASAN still works for CUDA host code). https://reviews.llvm.org/D27316 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX
jhen added a comment. In https://reviews.llvm.org/D27316#611162, @kcc wrote: > I am not sure this is going to work. > You essentially break on the first iteration in the beginning of the loop. > Why not exit the function before the loop? > Also, the loop "claims" the args and by breaking early you leave the args > unclaimed. > > I don't remember this code well enough to argue about it w/o tests. :( Thanks for taking a look. I just wanted to make sure nobody knew of a simple solution for this problem before I dug in further. Since none of us seems too familiar with this code, I'll do more investigation to try to find the right way to fix this. Once I do that I'll post it to this review (with a test or two to make sure it's working). https://reviews.llvm.org/D27316 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX
jhen updated this revision to Diff 80003. jhen added a comment. - "Support" ASAN in CudaToolChain https://reviews.llvm.org/D27316 Files: lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/cuda-no-sanitizers.cu Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,6 +6,7 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s +// CHECK-NOT: error: // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" Index: lib/Driver/ToolChains.h === --- lib/Driver/ToolChains.h +++ lib/Driver/ToolChains.h @@ -912,6 +912,8 @@ void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + SanitizerMask getSupportedSanitizers() const override; + const ToolChain &HostTC; CudaInstallationDetector CudaInstallation; Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -4973,6 +4973,15 @@ HostTC.AddIAMCUIncludeArgs(Args, CC1Args); } +SanitizerMask CudaToolChain::getSupportedSanitizers() const { + // The CudaToolChain only supports address sanitization in the sense that it + // allows ASAN arguments on the command line. It must not error out on these + // command line arguments because the host code compilation supports them. + // However, it doesn't actually do any address sanitization for device code; + // instead, it just ignores any ASAN command line arguments it sees. + return SanitizerKind::Address; +} + /// XCore tool chain XCoreToolChain::XCoreToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,6 +6,7 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s +// CHECK-NOT: error: // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" Index: lib/Driver/ToolChains.h === --- lib/Driver/ToolChains.h +++ lib/Driver/ToolChains.h @@ -912,6 +912,8 @@ void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + SanitizerMask getSupportedSanitizers() const override; + const ToolChain &HostTC; CudaInstallationDetector CudaInstallation; Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -4973,6 +4973,15 @@ HostTC.AddIAMCUIncludeArgs(Args, CC1Args); } +SanitizerMask CudaToolChain::getSupportedSanitizers() const { + // The CudaToolChain only supports address sanitization in the sense that it + // allows ASAN arguments on the command line. It must not error out on these + // command line arguments because the host code compilation supports them. + // However, it doesn't actually do any address sanitization for device code; + // instead, it just ignores any ASAN command line arguments it sees. + return SanitizerKind::Address; +} + /// XCore tool chain XCoreToolChain::XCoreToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27328: Remove faulty test from rL288448
jhen created this revision. jhen added a reviewer: jlebar. jhen added a subscriber: cfe-commits. The test introduced by https://reviews.llvm.org/rL288448 is currently failing because unimportant but unexpected errors appear as output from a test compile line. This patch removes the faulty test for now. Tomorrow I will come back and figure out how to put it back in a safe way. https://reviews.llvm.org/D27328 Files: test/Driver/cuda-no-sanitizers.cu Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,7 +6,6 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s -// CHECK-NOT: error: // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,7 +6,6 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s -// CHECK-NOT: error: // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27328: Remove faulty test from rL288448
jhen updated this revision to Diff 80012. jhen added a comment. - Switch to more specific error https://reviews.llvm.org/D27328 Files: test/Driver/cuda-no-sanitizers.cu Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,7 +6,7 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s -// CHECK-NOT: error: +// CHECK-NOT: error: unsupported option '-fsanitize=address' // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" Index: test/Driver/cuda-no-sanitizers.cu === --- test/Driver/cuda-no-sanitizers.cu +++ test/Driver/cuda-no-sanitizers.cu @@ -6,7 +6,7 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ // RUN: FileCheck %s -// CHECK-NOT: error: +// CHECK-NOT: error: unsupported option '-fsanitize=address' // CHECK-DAG: "-fcuda-is-device" // CHECK-NOT: "-fsanitize=address" // CHECK-DAG: "-triple" "x86_64--linux-gnu" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
jhen created this revision. jhen added a reviewer: jlebar. jhen added subscribers: cfe-commits, hfinkel. This is an improvement on https://reviews.llvm.org/rL288448 where address sanitization was listed as supported for the CudaToolChain. Since the intent is for the CudaToolChain not to reject any flags supported by the host compiler, this patch switches to forwarding the CudaToolChain sanitizer support to the host toolchain rather than explicitly whitelisting address sanitization. Thanks to hfinkel for this suggestion. https://reviews.llvm.org/D27351 Files: clang/lib/Driver/ToolChains.cpp Index: clang/lib/Driver/ToolChains.cpp === --- clang/lib/Driver/ToolChains.cpp +++ clang/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain Index: clang/lib/Driver/ToolChains.cpp === --- clang/lib/Driver/ToolChains.cpp +++ clang/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
This revision was automatically updated to reflect the committed changes. Closed by commit rL288512: [CUDA] Forward sanitizer support to host toolchain (authored by jhen). Changed prior to commit: https://reviews.llvm.org/D27351?vs=80082&id=80084#toc Repository: rL LLVM https://reviews.llvm.org/D27351 Files: cfe/trunk/lib/Driver/ToolChains.cpp Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits