[PATCH] D16501: [CUDA] Don't generate aliases for static extern "C" functions.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 22 17:43:02 PST 2016


jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: echristo, jhen, cfe-commits.

These aliases are done to support inline asm, but there's nothing we can
do: NVPTX doesn't support aliases.

http://reviews.llvm.org/D16501

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/alias.cu

Index: test/CodeGenCUDA/alias.cu
===================================================================
--- /dev/null
+++ test/CodeGenCUDA/alias.cu
@@ -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; }
+}
+}
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3836,6 +3836,10 @@
 /// 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16501.45781.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160123/e77aaee0/attachment.bin>


More information about the cfe-commits mailing list