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

Reply via email to