Skip to content

Commit f64448f

Browse files
committed
bpf: add constant pointer to helper-skb-ancestor-cgroup-id.c test
The purpose of this test is to make sure that constant propagation is achieved with the proper optimization level, so a BPF call instruction to a kernel helper is generated. This patch updates the patch so it also covers kernel helpers defined with constant static pointers. The motivation for this patch is: https://lore.kernel.org/bpf/[email protected]/T/#u Tested in bpf-unknown-none target x86_64-linux-gnu host. gcc/testsuite/ChangeLog * gcc.target/bpf/helper-skb-ancestor-cgroup-id.c: Add constant version of kernel helper static pointer.
1 parent ce61de1 commit f64448f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gcc/testsuite/gcc.target/bpf/helper-skb-ancestor-cgroup-id.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
struct __sk_buff;
77
static uint64_t (*bpf_skb_ancestor_cgroup_id)(struct __sk_buff *skb, int ancestor_level) = (void *) 83;
8+
static uint64_t (* const const_bpf_skb_ancestor_cgroup_id)(struct __sk_buff *skb, int ancestor_level) = (void *) 84;
89

910
void
1011
foo ()
@@ -13,7 +14,9 @@ foo ()
1314
void *skb;
1415
int ancestor_level;
1516

16-
ret = bpf_skb_ancestor_cgroup_id (skb, ancestor_level);
17+
ret = bpf_skb_ancestor_cgroup_id (skb, ancestor_level)
18+
+ const_bpf_skb_ancestor_cgroup_id (skb, ancestor_level);
1719
}
1820

1921
/* { dg-final { scan-assembler "call\t83" } } */
22+
/* { dg-final { scan-assembler "call\t84" } } */

0 commit comments

Comments
 (0)