[cfe-commits] r105975 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-address-space.cpp

Douglas Gregor dgregor at apple.com
Mon Jun 14 16:15:08 PDT 2010


Author: dgregor
Date: Mon Jun 14 18:15:08 2010
New Revision: 105975

URL: http://llvm.org/viewvc/llvm-project?rev=105975&view=rev
Log:
Add name mangling for address spaces. We use the vendor-extension
mangling for types, where the <source-name> is ASxxx (xxx is the
address-space number).

Added:
    cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp
Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=105975&r1=105974&r2=105975&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Mon Jun 14 18:15:08 2010
@@ -1050,6 +1050,18 @@
   if (Quals.hasConst())
     Out << 'K';
 
+  if (Quals.hasAddressSpace()) {
+    // Extension:
+    //
+    //   <type> ::= U <address-space-number>
+    // 
+    // where <address-space-number> is a source name consisting of 'AS' 
+    // followed by the address space <number>.
+    llvm::SmallString<64> ASString;
+    ASString = "AS" + llvm::utostr_32(Quals.getAddressSpace());
+    Out << 'U' << ASString.size() << ASString;
+  }
+  
   // FIXME: For now, just drop all extension qualifiers on the floor.
 }
 

Added: cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp?rev=105975&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp Mon Jun 14 18:15:08 2010
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_Z2f0Pc
+void f0(char *p) { }
+// CHECK: define void @_Z2f0PU3AS1c
+void f0(char __attribute__((address_space(1))) *p) { }





More information about the cfe-commits mailing list