111
|
1 #include "harness.h"
|
|
2
|
|
3 /* This problem occurs if a function is inlined. When its local
|
|
4 variables get allocated space on the caller's (the function to
|
|
5 which it is inlined) stack frame, they don't get 16-byte alignment
|
|
6 even if they need it. Here's an example with a union (that's the
|
|
7 first case I uncovered, but it's probably a general occurrence on
|
|
8 inlining). */
|
|
9
|
|
10 #define N 10
|
|
11 /* adjust N = size of buffer to try to get bad alignment for inlined union */
|
|
12
|
|
13 #define DO_INLINE __attribute__ ((always_inline))
|
|
14 #define DONT_INLINE __attribute__ ((noinline))
|
|
15
|
|
16 #ifdef __LITTLE_ENDIAN__
|
|
17 static inline DO_INLINE int inline_me(vector signed short data)
|
|
18 {
|
|
19 union {vector signed short v; signed short s[8];} u;
|
|
20 signed short x;
|
|
21 unsigned char x1, x2;
|
|
22
|
|
23 u.v = data;
|
|
24 x = u.s[7];
|
|
25 x1 = (x >> 8) & 0xff;
|
|
26 x2 = x & 0xff;
|
|
27 return ((x2 << 8) | x1);
|
|
28 }
|
|
29 #else
|
|
30 static inline DO_INLINE int inline_me(vector signed short data)
|
|
31 {
|
|
32 union {vector signed short v; signed short s[8];} u;
|
|
33 u.v = data;
|
|
34 return u.s[7];
|
|
35 }
|
|
36 #endif
|
|
37
|
|
38 static DONT_INLINE int foo(vector signed short data)
|
|
39 {
|
|
40 int c, buffer[N], i;
|
|
41 c = inline_me(data);
|
|
42 for (i=0; i<N; i++) {
|
|
43 if (i == 0)
|
|
44 buffer[i] = c;
|
|
45 else
|
|
46 buffer[i] = buffer[i-1] + c*i;
|
|
47 }
|
|
48 return buffer[N-1];
|
|
49 }
|
|
50
|
|
51 static void test()
|
|
52 {
|
|
53 check(foo((vector signed short)
|
|
54 ((vector unsigned char){1,2,3,4,5,6,7,8,
|
|
55 9,10,11,12,13,14,15,16})) == 0x2b4e0,
|
|
56 "foo");
|
|
57 }
|