| 1 | // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKNOOCL |
| 2 | // RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINNOOCL |
| 3 | // RUN: %clang_cc1 -cl-std=c++ -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKOCL |
| 4 | // RUN: %clang_cc1 -cl-std=c++ -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINOCL |
| 5 | |
| 6 | // CHECKNOOCL-LABEL: define {{.*}}void @_Z2f0Pc |
| 7 | // WINNOOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAD@Z" |
| 8 | // CHECKOCL-LABEL: define {{.*}}void @_Z2f0PU9CLgenericc |
| 9 | // WINOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_ASCLgeneric@$$CAD@__clang@@@Z" |
| 10 | void f0(char *p) { } |
| 11 | // CHECK-LABEL: define {{.*}}void @_Z2f0PU3AS1c |
| 12 | // WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$00$$CAD@__clang@@@Z" |
| 13 | void f0(char __attribute__((address_space(1))) *p) { } |
| 14 | |
| 15 | struct OpaqueType; |
| 16 | typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr; |
| 17 | |
| 18 | // CHECK-LABEL: define {{.*}}void @_Z2f0PU5AS10010OpaqueType |
| 19 | // WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$0GE@$$CAUOpaqueType@@@__clang@@@Z" |
| 20 | void f0(OpaqueTypePtr) { } |
| 21 | |
| 22 | // CHECK-LABEL: define {{.*}}void @_Z2f1PU3AS1Kc |
| 23 | // WIN-LABEL: define {{.*}}void @"?f1@@YAXPEAU?$_AS@$00$$CBD@__clang@@@Z" |
| 24 | void f1(char __attribute__((address_space(1))) const *p) {} |
| 25 | |
| 26 | // Ensure we can do return values, which change in MS mode. |
| 27 | // CHECK-LABEL: define {{.*}}float addrspace(1)* @_Z2f1PU3AS2Kc |
| 28 | // WIN-LABEL: define {{.*}}float addrspace(1)* @"?f1@@YAPEAU?$_AS@$00$$CAM@__clang@@PEAU?$_AS@$01$$CBD@2@@Z" |
| 29 | __attribute__((address_space(1))) float *f1(char __attribute__((address_space(2))) const *p) { return 0;} |
| 30 | |
| 31 | #if !defined(__OPENCL_CPP_VERSION__) |
| 32 | // Return value of address space without a pointer is invalid in opencl. |
| 33 | // Ensure we skip return values, since non-pointers aren't supposed to have an AS. |
| 34 | // CHECKNOOCL-LABEL: define {{.*}}float @_Z2f2PU3AS2Kc |
| 35 | // WINNOOCL-LABEL: define {{.*}}float @"?f2@@YA?AMQEAU?$_AS@$01$$CBD@__clang@@@Z" |
| 36 | __attribute__((address_space(1))) float f2(char __attribute__((address_space(2))) const * const p) { return 0;} |
| 37 | #endif |
| 38 | |
| 39 | #ifdef __OPENCL_CPP_VERSION__ |
| 40 | // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU9CLprivatec |
| 41 | // WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLprivate@$$CAD@__clang@@@Z" |
| 42 | void ocl_f0(char __private *p) { } |
| 43 | |
| 44 | struct ocl_OpaqueType; |
| 45 | typedef ocl_OpaqueType __global * ocl_OpaqueTypePtr; |
| 46 | |
| 47 | // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU8CLglobal14ocl_OpaqueType |
| 48 | // WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLglobal@$$CAUocl_OpaqueType@@@__clang@@@Z" |
| 49 | void ocl_f0(ocl_OpaqueTypePtr) { } |
| 50 | |
| 51 | // CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f1PU10CLconstantKc |
| 52 | // WINOCL-LABEL: define {{.*}}void @"?ocl_f1@@YAXPEAU?$_ASCLconstant@$$CBD@__clang@@@Z" |
| 53 | void ocl_f1(char __constant const *p) {} |
| 54 | |
| 55 | // Ensure we can do return values, which change in MS mode. |
| 56 | // CHECKOCL-LABEL: define {{.*}}float* @_Z6ocl_f1PU9CLgenericKc |
| 57 | // WINOCL-LABEL: define {{.*}}float* @"?ocl_f1@@YAPEAU?$_ASCLconstant@$$CAM@__clang@@PEAU?$_ASCLgeneric@$$CBD@2@@Z" |
| 58 | __constant float *ocl_f1(char __generic const *p) { return 0;} |
| 59 | |
| 60 | // Ensure we skip return values, since non-pointers aren't supposed to have an AS. |
| 61 | // CHECKOCL-LABEL: define {{.*}}float* @_Z6ocl_f2PU9CLgenericKc |
| 62 | // WINOCL-LABEL: define {{.*}}float* @"?ocl_f2@@YAPEAU?$_ASCLgeneric@$$CAM@__clang@@QEAU?$_ASCLgeneric@$$CBD@2@@Z" |
| 63 | __generic float *ocl_f2(__generic char const * const p) { return 0;} |
| 64 | #endif |
| 65 | |