1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -triple=arm64-apple-ios -emit-llvm -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -triple=arm64-apple-ios -emit-llvm -o - | FileCheck -check-prefix=CHECK-GLOBALS %s
3*0a6a1f1dSLionel Sambuc
4*0a6a1f1dSLionel Sambuc // __cxa_guard_acquire argument is 64-bit
5*0a6a1f1dSLionel Sambuc // rdar://11540122
6*0a6a1f1dSLionel Sambuc struct A {
7*0a6a1f1dSLionel Sambuc A();
8*0a6a1f1dSLionel Sambuc };
9*0a6a1f1dSLionel Sambuc
f()10*0a6a1f1dSLionel Sambuc void f() {
11*0a6a1f1dSLionel Sambuc // CHECK: call i32 @__cxa_guard_acquire(i64*
12*0a6a1f1dSLionel Sambuc static A a;
13*0a6a1f1dSLionel Sambuc }
14*0a6a1f1dSLionel Sambuc
15*0a6a1f1dSLionel Sambuc // ARM64 uses the C++11 definition of POD.
16*0a6a1f1dSLionel Sambuc // rdar://12650514
17*0a6a1f1dSLionel Sambuc namespace test1 {
18*0a6a1f1dSLionel Sambuc // This class is POD in C++11 and cannot have objects allocated in
19*0a6a1f1dSLionel Sambuc // its tail-padding.
20*0a6a1f1dSLionel Sambuc struct ABase {};
21*0a6a1f1dSLionel Sambuc struct A : ABase {
22*0a6a1f1dSLionel Sambuc int x;
23*0a6a1f1dSLionel Sambuc char c;
24*0a6a1f1dSLionel Sambuc };
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc struct B : A {
27*0a6a1f1dSLionel Sambuc char d;
28*0a6a1f1dSLionel Sambuc };
29*0a6a1f1dSLionel Sambuc
test()30*0a6a1f1dSLionel Sambuc int test() {
31*0a6a1f1dSLionel Sambuc return sizeof(B);
32*0a6a1f1dSLionel Sambuc }
33*0a6a1f1dSLionel Sambuc // CHECK: define i32 @_ZN5test14testEv()
34*0a6a1f1dSLionel Sambuc // CHECK: ret i32 12
35*0a6a1f1dSLionel Sambuc }
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc namespace std {
38*0a6a1f1dSLionel Sambuc class type_info;
39*0a6a1f1dSLionel Sambuc }
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc // ARM64 uses string comparisons for what would otherwise be
42*0a6a1f1dSLionel Sambuc // default-visibility weak RTTI. rdar://12650568
43*0a6a1f1dSLionel Sambuc namespace test2 {
44*0a6a1f1dSLionel Sambuc struct A {
45*0a6a1f1dSLionel Sambuc virtual void foo();
46*0a6a1f1dSLionel Sambuc };
foo()47*0a6a1f1dSLionel Sambuc void A::foo() {}
48*0a6a1f1dSLionel Sambuc // Tested below because these globals get kindof oddly rearranged.
49*0a6a1f1dSLionel Sambuc
50*0a6a1f1dSLionel Sambuc struct __attribute__((visibility("hidden"))) B {};
51*0a6a1f1dSLionel Sambuc const std::type_info &b0 = typeid(B);
52*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSN5test21BE = linkonce_odr hidden constant
53*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, i8* getelementptr inbounds ([11 x i8]* @_ZTSN5test21BE, i32 0, i32 0) }
54*0a6a1f1dSLionel Sambuc
55*0a6a1f1dSLionel Sambuc const std::type_info &b1 = typeid(B*);
56*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSPN5test21BE = linkonce_odr hidden constant
57*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, i8* getelementptr inbounds ([12 x i8]* @_ZTSPN5test21BE, i32 0, i32 0), i32 0, i8* bitcast
58*0a6a1f1dSLionel Sambuc
59*0a6a1f1dSLionel Sambuc struct C {};
60*0a6a1f1dSLionel Sambuc const std::type_info &c0 = typeid(C);
61*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSN5test21CE = linkonce_odr hidden constant
62*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIN5test21CE = linkonce_odr hidden constant { {{.*}}, i8* inttoptr (i64 add (i64 ptrtoint ([11 x i8]* @_ZTSN5test21CE to i64), i64 -9223372036854775808) to i8*) }
63*0a6a1f1dSLionel Sambuc
64*0a6a1f1dSLionel Sambuc const std::type_info &c1 = typeid(C*);
65*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSPN5test21CE = linkonce_odr hidden constant
66*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIPN5test21CE = linkonce_odr hidden constant { {{.*}}, i8* inttoptr (i64 add (i64 ptrtoint ([12 x i8]* @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to i8*), i32 0, i8* bitcast
67*0a6a1f1dSLionel Sambuc
68*0a6a1f1dSLionel Sambuc // This class is explicitly-instantiated, but that instantiation
69*0a6a1f1dSLionel Sambuc // doesn't guarantee to emit RTTI, so we can still demote the visibility.
70*0a6a1f1dSLionel Sambuc template <class T> class D {};
71*0a6a1f1dSLionel Sambuc template class D<int>;
72*0a6a1f1dSLionel Sambuc const std::type_info &d0 = typeid(D<int>);
73*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSN5test21DIiEE = linkonce_odr hidden constant
74*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIN5test21DIiEE = linkonce_odr hidden constant { {{.*}}, i8* inttoptr (i64 add (i64 ptrtoint ([14 x i8]* @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to i8*) }
75*0a6a1f1dSLionel Sambuc
76*0a6a1f1dSLionel Sambuc // This class is explicitly-instantiated and *does* guarantee to
77*0a6a1f1dSLionel Sambuc // emit RTTI, so we're stuck with having to use default visibility.
78*0a6a1f1dSLionel Sambuc template <class T> class E {
foo()79*0a6a1f1dSLionel Sambuc virtual void foo() {}
80*0a6a1f1dSLionel Sambuc };
81*0a6a1f1dSLionel Sambuc template class E<int>;
82*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSN5test21EIiEE = weak_odr constant [14 x i8]
83*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIN5test21EIiEE = weak_odr constant { {{.*}}, i8* inttoptr (i64 add (i64 ptrtoint ([14 x i8]* @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to i8*) }
84*0a6a1f1dSLionel Sambuc
85*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTSN5test21AE = constant [11 x i8]
86*0a6a1f1dSLionel Sambuc // CHECK-GLOBALS: @_ZTIN5test21AE = constant { {{.*}}, i8* getelementptr inbounds ([11 x i8]* @_ZTSN5test21AE, i32 0, i32 0) }
87*0a6a1f1dSLionel Sambuc
88*0a6a1f1dSLionel Sambuc }
89