]> granicus.if.org Git - clang/commitdiff
[CUDA] Don't generate aliases for static extern "C" functions.
authorJustin Lebar <jlebar@google.com>
Mon, 25 Jan 2016 22:36:37 +0000 (22:36 +0000)
committerJustin Lebar <jlebar@google.com>
Mon, 25 Jan 2016 22:36:37 +0000 (22:36 +0000)
Summary:
These aliases are done to support inline asm, but there's nothing we can
do: NVPTX doesn't support aliases.

Reviewers: tra

Subscribers: cfe-commits, jhen, echristo

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

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

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCUDA/alias.cu [new file with mode: 0644]

index 5a85de7e234fa4d07c8c803f4242f18c1d5b96b8..219f95e635e71dcd6d0206051f8eba10d41f4279 100644 (file)
@@ -3836,6 +3836,10 @@ static void EmitGlobalDeclMetadata(CodeGenModule &CGM,
 /// to such functions with an unmangled name from inline assembly within the
 /// same translation unit.
 void CodeGenModule::EmitStaticExternCAliases() {
+  // Don't do anything if we're generating CUDA device code -- the NVPTX
+  // assembly target doesn't support aliases.
+  if (Context.getTargetInfo().getTriple().isNVPTX())
+    return;
   for (auto &I : StaticExternCValues) {
     IdentifierInfo *Name = I.first;
     llvm::GlobalValue *Val = I.second;
diff --git a/test/CodeGenCUDA/alias.cu b/test/CodeGenCUDA/alias.cu
new file mode 100644 (file)
index 0000000..6efff6b
--- /dev/null
@@ -0,0 +1,17 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -o - %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// Check that we don't generate an alias from "foo" to the mangled name for
+// ns::foo() -- nvptx doesn't support aliases.
+
+namespace ns {
+extern "C" {
+// CHECK-NOT: @foo = internal alias
+__device__ __attribute__((used)) static int foo() { return 0; }
+}
+}