]> granicus.if.org Git - clang/commitdiff
[CUDA] Disable ctor/dtor aliases in device code.
authorJustin Lebar <jlebar@google.com>
Mon, 25 Jan 2016 22:36:35 +0000 (22:36 +0000)
committerJustin Lebar <jlebar@google.com>
Mon, 25 Jan 2016 22:36:35 +0000 (22:36 +0000)
Summary: NVPTX doesn't support aliases, so don't generate them.

Reviewers: tra

Subscribers: cfe-commits, jhen, echristo

Differential Revision: http://reviews.llvm.org/D16499

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258733 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/cuda-constructor-alias.cu [new file with mode: 0644]

index 814eb353c5cedf9d48d02e7acf8f8cb09765a4f4..6172baac43a89a8a6922a6d10a419c14ec1acf4a 100644 (file)
@@ -3985,9 +3985,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("Arguments");
   }
 
-  // Enable -mconstructor-aliases except on darwin, where we have to
-  // work around a linker bug;  see <rdar://problem/7651567>.
-  if (!getToolChain().getTriple().isOSDarwin())
+  // Enable -mconstructor-aliases except on darwin, where we have to work around
+  // a linker bug (see <rdar://problem/7651567>), and CUDA device code, where
+  // aliases aren't supported.
+  if (!getToolChain().getTriple().isOSDarwin() &&
+      !getToolChain().getTriple().isNVPTX())
     CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
diff --git a/test/Driver/cuda-constructor-alias.cu b/test/Driver/cuda-constructor-alias.cu
new file mode 100644 (file)
index 0000000..76f8e4f
--- /dev/null
@@ -0,0 +1,13 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Check that we don't pass -mconstructor-aliases to CUDA device-side
+// compilation, but we do pass it to host-side compilation.
+
+// RUN: %clang -### %s 2>&1 | FileCheck %s
+// CHECK: "-cc1"
+// CHECK-NOT: "-fcuda-is-device" {{.*}}"-mconstructor-aliases"
+// CHECK-NOT: "-mconstructor-aliases" {{.*}}"-fcuda-is-device"
+// CHECK: "-cc1"
+// CHECK-SAME: "-mconstructor-aliases"