[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / clang / test / CodeGenCXX / typeid-with-address-space.cpp
blob20699dc170acea931d1051648a88b138b7221d9d
1 // RUN: %clang_cc1 -I%S %s -triple amdgcn-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s
2 // RUN: %clang_cc1 -I%S %s -triple spirv64-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s --check-prefix=WITH-NONZERO-DEFAULT-AS
3 #include <typeinfo>
5 namespace Test1 {
7 // PR7400
8 struct A { virtual void f(); };
10 // CHECK: @_ZN5Test16int_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIi to ptr), align 8
11 // WITH-NONZERO-DEFAULT-AS: @_ZN5Test16int_tiE ={{.*}} constant ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTIi to ptr addrspace(4)), align 8
12 const std::type_info &int_ti = typeid(int);
14 // CHECK: @_ZN5Test14A_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIN5Test11AE to ptr), align 8
15 // WITH-NONZERO-DEFAULT-AS: @_ZN5Test14A_tiE ={{.*}} constant ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTIN5Test11AE to ptr addrspace(4)), align 8
16 const std::type_info &A_ti = typeid(const volatile A &);
18 volatile char c;
20 // CHECK: @_ZN5Test14c_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIc to ptr), align 8
21 // WITH-NONZERO-DEFAULT-AS: @_ZN5Test14c_tiE ={{.*}} constant ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTIc to ptr addrspace(4)), align 8
22 const std::type_info &c_ti = typeid(c);
24 extern const double &d;
26 // CHECK: @_ZN5Test14d_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTId to ptr), align 8
27 // WITH-NONZERO-DEFAULT-AS: @_ZN5Test14d_tiE ={{.*}} constant ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTId to ptr addrspace(4)), align 8
28 const std::type_info &d_ti = typeid(d);
30 extern A &a;
32 // CHECK: @_ZN5Test14a_tiE ={{.*}} global
33 const std::type_info &a_ti = typeid(a);
35 // CHECK: @_ZN5Test18A10_c_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIA10_c to ptr), align 8
36 // WITH-NONZERO-DEFAULT-AS: @_ZN5Test18A10_c_tiE ={{.*}} constant ptr addrspace(4) addrspacecast (ptr addrspace(1) @_ZTIA10_c to ptr addrspace(4)), align 8
37 const std::type_info &A10_c_ti = typeid(char const[10]);
39 // CHECK-LABEL: define{{.*}} ptr @_ZN5Test11fEv
40 // CHECK-SAME: personality ptr @__gxx_personality_v0
41 // WITH-NONZERO-DEFAULT-AS-LABEL: define{{.*}} ptr addrspace(4) @_ZN5Test11fEv
42 // WITH-NONZERO-DEFAULT-AS-SAME: personality ptr addrspace(4) @__gxx_personality_v0
43 const char *f() {
44 try {
45 // CHECK: br i1
46 // CHECK: invoke void @__cxa_bad_typeid() [[NR:#[0-9]+]]
47 // WITH-NONZERO-DEFAULT-AS: invoke{{.*}} void @__cxa_bad_typeid() [[NR:#[0-9]+]]
48 return typeid(*static_cast<A *>(0)).name();
49 } catch (...) {
50 // CHECK: landingpad { ptr, i32 }
51 // CHECK-NEXT: catch ptr null
52 // WITH-NONZERO-DEFAULT-AS: landingpad { ptr addrspace(4), i32 }
53 // WITH-NONZERO-DEFAULT-AS-NEXT: catch ptr addrspace(4) null
56 return 0;
61 // CHECK: attributes [[NR]] = { noreturn }