| 1 |
/* Test case for PR/67443. */ |
| 2 |
|
| 3 |
/* { dg-do run { target s390*-*-* } } */ |
| 4 |
/* { dg-prune-output "call-clobbered register used for global register variable" } */ |
| 5 |
/* { dg-options "-march=z900 -fPIC -fomit-frame-pointer -O3 -save-temps" } */ |
| 6 |
|
| 7 |
#include <assert.h> |
| 8 |
|
| 9 |
struct s_t |
| 10 |
{ |
| 11 |
unsigned f1 : 8; |
| 12 |
unsigned f2 : 24; |
| 13 |
}; |
| 14 |
|
| 15 |
__attribute__ ((noinline)) |
| 16 |
int bar () |
| 17 |
{ |
| 18 |
return 0; |
| 19 |
} |
| 20 |
|
| 21 |
__attribute__ ((noinline)) |
| 22 |
void foo (struct s_t *ps, int c) |
| 23 |
{ |
| 24 |
int tmp; |
| 25 |
|
| 26 |
/* Uses r2 as address register. */ |
| 27 |
ps->f1 = c; |
| 28 |
/* Clobber all registers that r2 could be stored into. */ |
| 29 |
__asm__ __volatile__ ("" : : : "memory", |
| 30 |
"r0","r1","r6","r7","r8","r9","r10","r11"); |
| 31 |
/* Force that the pointer is evicted from r2 and stored on the stack. */ |
| 32 |
tmp = bar (); |
| 33 |
/* User the pointer again. It gets reloaded to a different register because |
| 34 |
r2 is already occupied. */ |
| 35 |
ps->f2 = tmp; |
| 36 |
/* If dead store elimination fails to detect that the address in r2 during |
| 37 |
the first assignment is an alias of the address in rX during the second |
| 38 |
assignment, it eliminates the first assignment and the f1 field is not |
| 39 |
written (bug). */ |
| 40 |
} |
| 41 |
/* Make sure that r2 is used only once as an address register for storing. |
| 42 |
If this check fails, the test case needs to be fixed. |
| 43 |
{ dg-final { scan-assembler-times "\tst.\?\t.*,0\\(%r2\\)" 1 } } */ |
| 44 |
|
| 45 |
int main (void) |
| 46 |
{ |
| 47 |
struct s_t s = { 0x01u, 0x020304u }; |
| 48 |
|
| 49 |
foo (&s, 0); |
| 50 |
assert (s.f1 == 0&& s.f2 == 0); |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |