diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 011e46941d18..e1e2f1069b71 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -1050,6 +1050,18 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals) { if (Quals.hasConst()) Out << 'K'; + if (Quals.hasAddressSpace()) { + // Extension: + // + // ::= U + // + // where is a source name consisting of 'AS' + // followed by the address space . + 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. } diff --git a/clang/test/CodeGenCXX/mangle-address-space.cpp b/clang/test/CodeGenCXX/mangle-address-space.cpp new file mode 100644 index 000000000000..fbbcbfa35b58 --- /dev/null +++ b/clang/test/CodeGenCXX/mangle-address-space.cpp @@ -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) { }