77 lines · cpp
1// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKNOOCL2// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINNOOCL3// RUN: %clang_cc1 -cl-std=clc++ -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK,CHECKOCL4// RUN: %clang_cc1 -cl-std=clc++ -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN,WINOCL5 6// CHECKNOOCL-LABEL: define {{.*}}void @_Z2f0Pc7// WINNOOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAD@Z"8// CHECKOCL-LABEL: define {{.*}}void @_Z2f0PU9CLgenericc9// WINOCL-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_ASCLgeneric@$$CAD@__clang@@@Z" 10void f0(char *p) { }11// CHECK-LABEL: define {{.*}}void @_Z2f0PU3AS1c12// WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$00$$CAD@__clang@@@Z"13void f0(char __attribute__((address_space(1))) *p) { }14 15struct OpaqueType;16typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr;17 18// CHECK-LABEL: define {{.*}}void @_Z2f0PU5AS10010OpaqueType19// WIN-LABEL: define {{.*}}void @"?f0@@YAXPEAU?$_AS@$0GE@$$CAUOpaqueType@@@__clang@@@Z"20void f0(OpaqueTypePtr) { }21 22// CHECK-LABEL: define {{.*}}void @_Z2f1PU3AS1Kc23// WIN-LABEL: define {{.*}}void @"?f1@@YAXPEAU?$_AS@$00$$CBD@__clang@@@Z"24void 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 {{.*}}ptr addrspace(1) @_Z2f1PU3AS2Kc28// WIN-LABEL: define {{.*}}ptr 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 @_Z2f2PU3AS2Kc35// 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#endif38 39#ifdef __OPENCL_CPP_VERSION__40// CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU9CLprivatec41// WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLprivate@$$CAD@__clang@@@Z"42void ocl_f0(char __private *p) { }43 44struct ocl_OpaqueType;45typedef ocl_OpaqueType __global * ocl_OpaqueTypePtr;46typedef ocl_OpaqueType __attribute__((opencl_global_host)) * ocl_OpaqueTypePtrH;47typedef ocl_OpaqueType48 __attribute__((opencl_global_device)) *49 ocl_OpaqueTypePtrD;50 51// CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f0PU8CLglobal14ocl_OpaqueType52// WINOCL-LABEL: define {{.*}}void @"?ocl_f0@@YAXPEAU?$_ASCLglobal@$$CAUocl_OpaqueType@@@__clang@@@Z"53void ocl_f0(ocl_OpaqueTypePtr) { }54 55// CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f1PU10CLconstantKc56// WINOCL-LABEL: define {{.*}}void @"?ocl_f1@@YAXPEAU?$_ASCLconstant@$$CBD@__clang@@@Z"57void ocl_f1(char __constant const *p) {}58 59// Ensure we can do return values, which change in MS mode.60// CHECKOCL-LABEL: define {{.*}}ptr @_Z6ocl_f1PU9CLgenericKc61// WINOCL-LABEL: define {{.*}}ptr @"?ocl_f1@@YAPEAU?$_ASCLconstant@$$CAM@__clang@@PEAU?$_ASCLgeneric@$$CBD@2@@Z"62__constant float *ocl_f1(char __generic const *p) { return 0;}63 64// Ensure we skip return values, since non-pointers aren't supposed to have an AS.65// CHECKOCL-LABEL: define {{.*}}ptr @_Z6ocl_f2PU9CLgenericKc66// WINOCL-LABEL: define {{.*}}ptr @"?ocl_f2@@YAPEAU?$_ASCLgeneric@$$CAM@__clang@@QEAU?$_ASCLgeneric@$$CBD@2@@Z"67__generic float *ocl_f2(__generic char const * const p) { return 0;}68 69// CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f3PU6CLhost14ocl_OpaqueType70// WINOCL-LABEL: define {{.*}}void @"?ocl_f3@@YAXPEAU?$_ASCLhost@$$CAUocl_OpaqueType@@@__clang@@@Z"71void ocl_f3(ocl_OpaqueTypePtrH) {}72 73// CHECKOCL-LABEL: define {{.*}}void @_Z6ocl_f4PU8CLdevice14ocl_OpaqueType74// WINOCL-LABEL: define {{.*}}void @"?ocl_f4@@YAXPEAU?$_ASCLdevice@$$CAUocl_OpaqueType@@@__clang@@@Z"75void ocl_f4(ocl_OpaqueTypePtrD) {}76#endif77