Index: lib/AST/ItaniumMangle.cpp =================================================================== --- lib/AST/ItaniumMangle.cpp +++ lib/AST/ItaniumMangle.cpp @@ -1796,6 +1796,7 @@ case LangAS::opencl_global: ASString = "CLglobal"; break; case LangAS::opencl_local: ASString = "CLlocal"; break; case LangAS::opencl_constant: ASString = "CLconstant"; break; + case LangAS::opencl_generic: ASString = "CLgeneric"; break; // ::= "CU" [ "device" | "constant" | "shared" ] case LangAS::cuda_device: ASString = "CUdevice"; break; case LangAS::cuda_constant: ASString = "CUconstant"; break; Index: lib/AST/MicrosoftMangle.cpp =================================================================== --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -1383,6 +1383,37 @@ } } + if (Quals.hasAddressSpace()) { + // Address space extension: + // + // ::= U + // ::= U + // ::= U + + SmallString<64> ASString; + unsigned AS = Quals.getAddressSpace(); + + if (Context.getASTContext().addressSpaceMapManglingFor(AS)) { + // ::= "AS" + unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS); + ASString = "AS" + llvm::utostr(TargetAS); + } else { + switch (AS) { + default: llvm_unreachable("Not a language specific address space"); + // ::= "CL" [ "global" | "local" | "constant" ] + case LangAS::opencl_global: ASString = "CLglobal"; break; + case LangAS::opencl_local: ASString = "CLlocal"; break; + case LangAS::opencl_constant: ASString = "CLconstant"; break; + case LangAS::opencl_generic: ASString = "CLgeneric"; break; + // ::= "CU" [ "device" | "constant" | "shared" ] + case LangAS::cuda_device: ASString = "CUdevice"; break; + case LangAS::cuda_constant: ASString = "CUconstant"; break; + case LangAS::cuda_shared: ASString = "CUshared"; break; + } + } + Out << 'U' << ASString.size() << ASString; + } + // FIXME: For now, just drop all extension qualifiers on the floor. } Index: test/CodeGenOpenCL/generic-mangling-itanium.cl =================================================================== --- test/CodeGenOpenCL/generic-mangling-itanium.cl +++ test/CodeGenOpenCL/generic-mangling-itanium.cl @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x cl -cl-std=CL2.0 -o - %s | FileCheck %s + +// CHECK: _Z30atomic_compare_exchange_strongPVU8CLglobalU7_AtomiciPU9CLgenericii +bool __attribute__((__overloadable__)) atomic_compare_exchange_strong( + volatile __global atomic_int *object, + int *expected, + int desired) +{ + return atomic_compare_exchange_strong_explicit( + object, expected, desired, 1, 2); +} Index: test/CodeGenOpenCL/generic-mangling-microsoft.cl =================================================================== --- test/CodeGenOpenCL/generic-mangling-microsoft.cl +++ test/CodeGenOpenCL/generic-mangling-microsoft.cl @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -x cl -cl-std=CL2.0 -o - %s | FileCheck %s + +// CHECK: define zeroext i1 @"\01?atomic_compare_exchange_strong@@$$J0YA_NPCU8CLglobalU?$_Atomic@H@__clang@@PAU9CLgenericHH@Z"(i32* %object, i32* %expected, i32 %desired) +bool __attribute__((__overloadable__)) atomic_compare_exchange_strong( + volatile __global atomic_int *object, + int *expected, + int desired) +{ + return atomic_compare_exchange_strong_explicit( + object, expected, desired, 1, 2); +}