1 // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
3 #define __private__ __attribute__((address_space(5)))
5 void func_pchar(__private__
char *x
);
6 void func_pvoid(__private__
void *x
);
7 void func_pint(__private__
int *x
);
12 class Derived
: public Base
{
16 __private__ Base
*b
= (__private__ Base
*)p
;
19 // CHECK-LABEL: test_cast
20 void test_cast(char *gen_char_ptr
, void *gen_void_ptr
, int *gen_int_ptr
) {
21 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
22 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
23 __private__
char *priv_char_ptr
= (__private__
char *)gen_char_ptr
;
25 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
26 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
27 priv_char_ptr
= (__private__
char *)gen_void_ptr
;
29 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
30 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
31 priv_char_ptr
= (__private__
char *)gen_int_ptr
;
33 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
34 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
35 __private__
void *priv_void_ptr
= (__private__
void *)gen_char_ptr
;
37 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
38 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
39 priv_void_ptr
= (__private__
void *)gen_void_ptr
;
41 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
42 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
43 priv_void_ptr
= (__private__
void *)gen_int_ptr
;
45 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
46 // CHECK-NEXT: store ptr addrspace(5) %[[cast]]
47 __private__
int *priv_int_ptr
= (__private__
int *)gen_void_ptr
;
49 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
50 // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
51 func_pchar((__private__
char *)gen_char_ptr
);
53 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
54 // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
55 func_pchar((__private__
char *)gen_void_ptr
);
57 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
58 // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
59 func_pchar((__private__
char *)gen_int_ptr
);
61 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
62 // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
63 func_pvoid((__private__
void *)gen_char_ptr
);
65 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
66 // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
67 func_pvoid((__private__
void *)gen_void_ptr
);
69 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
70 // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
71 func_pvoid((__private__
void *)gen_int_ptr
);
73 // CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
74 // CHECK-NEXT: call void @_Z9func_pintPU3AS5i(ptr addrspace(5) noundef %[[cast]])
75 func_pint((__private__
int *)gen_void_ptr
);