| 1 |
/* { dg-do run { xfail { { cris-*-* sparc*-*-* } || { { ! lp64 } && hppa*-*-* } } } } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
#include <inttypes.h> |
| 5 |
|
| 6 |
#ifdef __CRIS__ |
| 7 |
#define OUTGOING_SP_OFFSET (-sizeof (void *)) |
| 8 |
/* Suggestion: append #elif defined(__<TARGET-IDENTIFIER>__) after this comment, |
| 9 |
either defining OUTGOING_SP_OFFSET to whatever the pertinent amount is at -O2, |
| 10 |
if that makes your target consistently fail this test, or define |
| 11 |
DO_NOT_TAMPER for more complicated situations. Either way, compile with |
| 12 |
-DDO_NO_TAMPER to avoid any meddling. */ |
| 13 |
#endif |
| 14 |
|
| 15 |
#if defined (OUTGOING_SP_OFFSET) && !defined (DO_NOT_TAMPER) |
| 16 |
extern int xmain () __attribute__ ((__noipa__)); |
| 17 |
int main () |
| 18 |
{ |
| 19 |
uintptr_t misalignment |
| 20 |
= (OUTGOING_SP_OFFSET |
| 21 |
+ (15 & (uintptr_t) __builtin_stack_address ())); |
| 22 |
/* Allocate a minimal amount if the stack was accidentally aligned. */ |
| 23 |
void *q = __builtin_alloca (misalignment == 0); |
| 24 |
xmain (); |
| 25 |
/* Fake use to avoid the "allocation" being optimized out. */ |
| 26 |
asm volatile ("" : : "rm" (q)); |
| 27 |
return 0; |
| 28 |
} |
| 29 |
#define main xmain |
| 30 |
#endif |
| 31 |
|
| 32 |
struct U { |
| 33 |
int M0; |
| 34 |
int M1; |
| 35 |
} __attribute ((aligned (16))); |
| 36 |
|
| 37 |
volatile struct U p0 = {1, 0}; |
| 38 |
|
| 39 |
void __attribute__ ((noinline)) |
| 40 |
foo (struct U p) |
| 41 |
{ |
| 42 |
|
| 43 |
volatile intptr_t mask = 0b1111; |
| 44 |
volatile int dummy[2]; |
| 45 |
struct U p1 = p; |
| 46 |
dummy[1] = p.M0; |
| 47 |
|
| 48 |
if ((intptr_t)(&p1) & mask) |
| 49 |
__builtin_abort (); |
| 50 |
if ((intptr_t)(&p) & mask) |
| 51 |
__builtin_abort (); |
| 52 |
|
| 53 |
if (p1.M0 != dummy[1]) |
| 54 |
__builtin_abort (); |
| 55 |
if (p1.M1 != p.M1) |
| 56 |
__builtin_abort (); |
| 57 |
} |
| 58 |
|
| 59 |
int |
| 60 |
main () |
| 61 |
{ |
| 62 |
foo (p0); |
| 63 |
return 0; |
| 64 |
} |