150
|
1 // TLS variable cannot be aligned to more than 32 bytes on PS4.
|
|
2
|
236
|
3 // RUN: %clang_cc1 -triple x86_64-scei-ps4 -std=c++17 -fsyntax-only -verify %s
|
150
|
4
|
|
5
|
|
6 // A non-aligned type.
|
|
7 struct non_aligned_struct {
|
|
8 int some_data[16]; // 64 bytes of stuff, non aligned.
|
|
9 };
|
|
10
|
|
11 // An aligned type.
|
|
12 struct __attribute__(( aligned(64) )) aligned_struct {
|
|
13 int some_data[12]; // 48 bytes of stuff, aligned to 64.
|
|
14 };
|
|
15
|
|
16 // A type with an aligned field.
|
|
17 struct struct_with_aligned_field {
|
|
18 int some_aligned_data[12] __attribute__(( aligned(64) )); // 48 bytes of stuff, aligned to 64.
|
|
19 };
|
|
20
|
236
|
21 // A templated type
|
|
22 template <typename>
|
|
23 struct templated_struct {};
|
|
24 // expected-note@-1{{candidate template ignored: couldn't infer template argument ''}}
|
|
25 // expected-note@-2{{candidate function template not viable: requires 1 argument, but 0 were provided}}
|
|
26
|
150
|
27 // A typedef of the aligned struct.
|
|
28 typedef aligned_struct another_aligned_struct;
|
|
29
|
|
30 // A typedef to redefine a non-aligned struct as aligned.
|
|
31 typedef __attribute__(( aligned(64) )) non_aligned_struct yet_another_aligned_struct;
|
|
32
|
|
33 // Non aligned variable doesn't cause an error.
|
|
34 __thread non_aligned_struct foo;
|
|
35
|
|
36 // Variable aligned because of its type should cause an error.
|
|
37 __thread aligned_struct bar; // expected-error{{alignment (64) of thread-local variable}}
|
|
38
|
|
39 // Variable explicitly aligned in the declaration should cause an error.
|
|
40 __thread non_aligned_struct bar2 __attribute__(( aligned(64) )); // expected-error{{alignment (64) of thread-local variable}}
|
|
41
|
|
42 // Variable aligned because of one of its fields should cause an error.
|
|
43 __thread struct_with_aligned_field bar3; // expected-error{{alignment (64) of thread-local variable}}
|
|
44
|
|
45 // Variable aligned because of typedef, first case.
|
|
46 __thread another_aligned_struct bar4; // expected-error{{alignment (64) of thread-local variable}}
|
|
47
|
|
48 // Variable aligned because of typedef, second case.
|
|
49 __thread yet_another_aligned_struct bar5; // expected-error{{alignment (64) of thread-local variable}}
|
|
50
|
236
|
51 // No crash for undeduced type.
|
|
52 __thread templated_struct bar6; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'templated_struct'}}
|
|
53
|
150
|
54 int baz ()
|
|
55 {
|
|
56 return foo.some_data[0] + bar.some_data[1] + bar2.some_data[2] +
|
|
57 bar3.some_aligned_data[3] + bar4.some_data[4] +
|
|
58 bar5.some_data[5];
|
|
59 }
|
|
60
|
|
61 template<class T> struct templated_tls {
|
|
62 static __thread T t;
|
|
63 T other_t __attribute__(( aligned(64) ));
|
|
64 };
|
236
|
65 __thread templated_tls<int> blah; // expected-error{{alignment (64) of thread-local variable}}
|
150
|
66
|
|
67 template <int N>
|
|
68 struct S {
|
236
|
69 struct alignas(64) B {};
|
|
70 struct alignas(N) C {};
|
|
71 static inline void f() {
|
|
72 thread_local B b; // expected-error{{alignment (64) of thread-local variable}}
|
|
73 thread_local C c; // expected-error{{alignment (64) of thread-local variable}}
|
|
74 }
|
|
75 template<int J> static inline thread_local int b alignas(J) = J; // expected-error{{alignment (64) of thread-local variable}}
|
150
|
76 static int __thread __attribute__((aligned(N))) x; // expected-error{{alignment (64) of thread-local variable}}
|
|
77 };
|
|
78
|
236
|
79 int blag() {
|
|
80 // Verify alignment check where the alignment is a template parameter.
|
|
81 // The check is only performed during instantiation.
|
|
82 S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
|
|
83
|
|
84 // Verify alignment for dependent local variables.
|
|
85 S<64>::f(); // expected-note{{in instantiation of member function 'S<64>::f' requested here}}
|
|
86
|
|
87 // Verify alignment check where a dependent type is involved.
|
|
88 // The check is (correctly) not performed on "t", but the check still is
|
|
89 // performed on the structure as a whole once it has been instantiated.
|
|
90 return blah.other_t * 2 + S<64>::b<64>; // expected-note{{in instantiation of static data member 'S<64>::b' requested here}}
|
|
91 }
|