| 1 |
/* Test to make sure CO-RE access relocs point to non const versions of the |
| 2 |
type. */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ |
| 6 |
|
| 7 |
struct S { |
| 8 |
int a; |
| 9 |
int b; |
| 10 |
int c; |
| 11 |
} __attribute__((preserve_access_index)); |
| 12 |
|
| 13 |
void |
| 14 |
func (struct S * s) |
| 15 |
{ |
| 16 |
int *x; |
| 17 |
int *y; |
| 18 |
int *z; |
| 19 |
struct S tmp; |
| 20 |
const struct S *cs = s; |
| 21 |
volatile struct S *vs = s; |
| 22 |
|
| 23 |
/* 0:2 */ |
| 24 |
x = &(s->c); |
| 25 |
|
| 26 |
/* 0:1 */ |
| 27 |
y = (int *) &(cs->b); |
| 28 |
|
| 29 |
/* 0:1 */ |
| 30 |
z = (int *) &(vs->b); |
| 31 |
|
| 32 |
*x = 4; |
| 33 |
*y = 4; |
| 34 |
*z = 4; |
| 35 |
} |
| 36 |
|
| 37 |
/* Both const and non const struct type should have the same bpfcr_type. */ |
| 38 |
/* { dg-final { scan-assembler-times "0x1\t# bpfcr_type \\(struct S\\)" 1 } } */ |
| 39 |
/* { dg-final { scan-assembler-times "0x1\t# bpfcr_type \\(const struct S\\)" 1 } } */ |
| 40 |
/* { dg-final { scan-assembler-times "0x1\t# bpfcr_type \\(volatile struct S\\)" 1 } } */ |