Debian Codegraph @

gcc/testsuite/gcc.target/bpf/core-attr-calls.c

raw
1 /* Test for BPF CO-RE __attribute__((preserve_access_index)) with accesses on
2 LHS and both LHS and RHS of assignment with calls involved. */
3
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -dA -gbtf -mco-re -masm=normal" } */
6
7 struct U {
8 int c;
9 struct V {
10 int d;
11 int e[4];
12 int f;
13 int *g;
14 } v;
15 };
16
17 struct T {
18 int a;
19 int b;
20 struct U u;
21 struct U *ptr_u;
22 struct U *array_u;
23 } __attribute__((preserve_access_index));
24
25 extern struct U *get_other_u(struct U *);
26 extern struct V *get_other_v(struct V *);
27
28 void
29 func (struct T *t, int i)
30 {
31 /* Since we are using the builtin all accesses are converted to CO-RE. */
32 /* 0:3 0:0 */
33 __builtin_preserve_access_index(({ get_other_u(t->ptr_u)->c = 42; }));
34
35 /* This should not pass-through CO-RE accesses beyond the call since struct U
36 is not explicitly marked with preserve_access_index. */
37 /* 0:3 */
38 get_other_u(t->ptr_u)->c = 43;
39
40 /* 0:2:1 */
41 get_other_v(&t->u.v)->d = 44;
42 }
43
44 /* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:3\"\\)" 2 } } */
45 /* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:0\"\\)" 1 } } */
46 /* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:2:1\"\\)" 1 } } */
47 /* { dg-final { scan-assembler-times "bpfcr_type \\(struct T\\)" 3 } } */
48 /* { dg-final { scan-assembler-times "bpfcr_type \\(struct U\\)" 1 } } */
49