xref: /aosp_15_r20/external/clang/test/CodeGenCXX/armv7k.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck %s
2*67e74705SXin Li // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck -check-prefix=CHECK-GLOBALS %s
3*67e74705SXin Li 
4*67e74705SXin Li // __cxa_guard_acquire argument is 64-bit
5*67e74705SXin Li // rdar://11540122
6*67e74705SXin Li struct A {
7*67e74705SXin Li   A();
8*67e74705SXin Li };
9*67e74705SXin Li 
f()10*67e74705SXin Li void f() {
11*67e74705SXin Li   // CHECK: call i32 @__cxa_guard_acquire(i32*
12*67e74705SXin Li   static A a;
13*67e74705SXin Li }
14*67e74705SXin Li 
15*67e74705SXin Li // ARM64 uses the C++11 definition of POD.
16*67e74705SXin Li // rdar://12650514
17*67e74705SXin Li namespace test1 {
18*67e74705SXin Li   // This class is POD in C++11 and cannot have objects allocated in
19*67e74705SXin Li   // its tail-padding.
20*67e74705SXin Li   struct ABase {};
21*67e74705SXin Li   struct A : ABase {
22*67e74705SXin Li     int x;
23*67e74705SXin Li     char c;
24*67e74705SXin Li   };
25*67e74705SXin Li 
26*67e74705SXin Li   struct B : A {
27*67e74705SXin Li     char d;
28*67e74705SXin Li   };
29*67e74705SXin Li 
test()30*67e74705SXin Li   int test() {
31*67e74705SXin Li     return sizeof(B);
32*67e74705SXin Li   }
33*67e74705SXin Li   // CHECK: define i32 @_ZN5test14testEv()
34*67e74705SXin Li   // CHECK: ret i32 12
35*67e74705SXin Li }
36*67e74705SXin Li 
37*67e74705SXin Li namespace std {
38*67e74705SXin Li   class type_info;
39*67e74705SXin Li }
40*67e74705SXin Li 
41*67e74705SXin Li // ARM64 uses string comparisons for what would otherwise be
42*67e74705SXin Li // default-visibility weak RTTI.  rdar://12650568
43*67e74705SXin Li namespace test2 {
44*67e74705SXin Li   struct A {
45*67e74705SXin Li     virtual void foo();
46*67e74705SXin Li   };
foo()47*67e74705SXin Li   void A::foo() {}
48*67e74705SXin Li   // Tested below because these globals get kindof oddly rearranged.
49*67e74705SXin Li 
50*67e74705SXin Li   struct __attribute__((visibility("hidden"))) B {};
51*67e74705SXin Li   const std::type_info &b0 = typeid(B);
52*67e74705SXin Li   // CHECK-GLOBALS: @_ZTSN5test21BE = linkonce_odr hidden constant
53*67e74705SXin Li   // CHECK-GLOBALS: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTSN5test21BE, i32 0, i32 0) }
54*67e74705SXin Li 
55*67e74705SXin Li   const std::type_info &b1 = typeid(B*);
56*67e74705SXin Li   // CHECK-GLOBALS: @_ZTSPN5test21BE = linkonce_odr hidden constant
57*67e74705SXin Li   // CHECK-GLOBALS: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @_ZTSPN5test21BE, i32 0, i32 0), i32 0, i8* bitcast
58*67e74705SXin Li 
59*67e74705SXin Li   struct C {};
60*67e74705SXin Li   const std::type_info &c0 = typeid(C);
61*67e74705SXin Li   // CHECK-GLOBALS: @_ZTSN5test21CE = linkonce_odr constant [11 x i8] c"N5test21CE\00"
62*67e74705SXin Li   // CHECK-GLOBALS: @_ZTIN5test21CE = linkonce_odr constant { {{.*}}, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTSN5test21CE, i32 0, i32 0) }
63*67e74705SXin Li }
64*67e74705SXin Li 
65*67e74705SXin Li // va_list should be based on "char *" rather than "void *".
66*67e74705SXin Li 
67*67e74705SXin Li // CHECK: define void @_Z11whatsVaListPc
whatsVaList(__builtin_va_list l)68*67e74705SXin Li void whatsVaList(__builtin_va_list l) {}
69