new file mode 100644
@@ -0,0 +1,41 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't an eBPF target.
+if ![istarget bpf-*-*] then {
+ return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
new file mode 100644
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -std=gnu99" } */
+
+void foo ()
+{
+ long long ll, off;
+
+ /* Indirect. */
+ ll = __builtin_bpf_load_byte (off);
+ ll = __builtin_bpf_load_half (off);
+ ll = __builtin_bpf_load_word (off);
+
+ /* Absolute. */
+ ll = __builtin_bpf_load_byte (0);
+ ll = __builtin_bpf_load_half (4);
+ ll = __builtin_bpf_load_word (8);
+}
+
+/* { dg-final { scan-assembler "ldindb\t%r.,0.*ldindh\t%r.,0.*ldindw\t%r.,0" } } */
+/* { dg-final { scan-assembler "ldabsb\t0.*ldabsh\t4.*ldabsw\t8" } } */
new file mode 100644
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-xfail-if "" { bpf-*-* } } */
+
+typedef void *(*T)(void);
+f1 ()
+{
+ ((T) 0)();
+}
+f2 ()
+{
+ ((T) 1000)();
+}
+f3 ()
+{
+ ((T) 1000000)();
+}
+
+/* { dg-final { scan-assembler "call\t0" } } */
+/* { dg-final { scan-assembler "call\t1000" } } */
+/* { dg-final { scan-assembler "call\t10000" } } */
new file mode 100644
@@ -0,0 +1,26 @@
+/* Verify proper errors are generated for functions taking too many
+ arguments, with aggregates and 128-bit arguments. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+#include <stdint.h>
+
+struct ja
+{
+ long i1;
+ long i2;
+ long i3;
+ long i4;
+ long i5;
+ long i6;
+};
+
+void jorl (struct ja, unsigned __int128, unsigned __int128, int i3);
+
+int foo ()
+{
+ struct ja je;
+ jorl (je, 1, 2, 3); /* { dg-error "too many function arguments" } */
+ return 2L /1;
+}
+
new file mode 100644
@@ -0,0 +1,26 @@
+/* Verify proper errors are generated for functions taking too many
+ arguments, with aggregates and 128-bit arguments. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+#include <stdint.h>
+
+struct ja
+{
+ long i1;
+ long i2;
+ long i3;
+ long i4;
+ long i5;
+ long i6;
+};
+
+void jorl (struct ja, int, int, int, unsigned __int128);
+
+int foo ()
+{
+ struct ja je;
+ jorl (je, 1, 2, 3, 4); /* { dg-error "too many function arguments" } */
+ return 2L /1;
+}
+
new file mode 100644
@@ -0,0 +1,15 @@
+/* Verify proper errors are generated for functions taking too many
+ arguments. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int
+foo (int a1, /* { dg-error "too many function arguments" } */
+ int a2,
+ int a3,
+ int a4,
+ int a5,
+ int a6)
+{
+ return a6;
+}
new file mode 100644
@@ -0,0 +1,11 @@
+/* Verify proper errors are generated for indirect function calls. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+void (*fnp) (void);
+
+void
+foo ()
+{
+ (*fnp) ();
+} /* { dg-error "indirect call in function" } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *addr;
+ int addr_len;
+
+ ret = __builtin_bpf_helper_bind (ctx, addr, addr_len);
+}
+
+/* { dg-final { scan-assembler "call\t64" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ uint32_t ifindex;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_redirect (ifindex, flags);
+}
+
+/* { dg-final { scan-assembler "call\t23" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t ifindex;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_clone_redirect (skb, ifindex, flags);
+}
+
+/* { dg-final { scan-assembler "call\t13" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int64_t ret;
+ int32_t *to, *from;
+ uint64_t to_size, from_size;
+ int seed;
+
+ ret = __builtin_bpf_helper_csum_diff (from, from_size, to, to_size, seed);
+}
+
+/* { dg-final { scan-assembler "call\t28" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int64_t ret;
+ void *skb;
+ int csum;
+
+ ret = __builtin_bpf_helper_csum_update (skb, csum);
+}
+
+/* { dg-final { scan-assembler "call\t40" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *map;
+ uint32_t index;
+
+ ret = __builtin_bpf_helper_current_task_under_cgroup (map, index);
+}
+
+/* { dg-final { scan-assembler "call\t37" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *params;
+ int plen;
+ uint32_t flags;
+
+ ret = __builtin_bpf_helper_fib_lookup (ctx, params, plen, flags);
+}
+
+/* { dg-final { scan-assembler "call\t69" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_get_cgroup_classid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t17" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+
+ ret = __builtin_bpf_helper_get_current_cgroup_id ();
+}
+
+/* { dg-final { scan-assembler "call\t80" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *buf;
+ uint32_t size_of_buf;
+
+ ret = __builtin_bpf_helper_get_current_comm (buf, size_of_buf);
+}
+
+/* { dg-final { scan-assembler "call\t16" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+
+ ret = __builtin_bpf_helper_get_current_pid_tgid ();
+}
+
+/* { dg-final { scan-assembler "call\t14" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+
+ ret = __builtin_bpf_helper_get_current_task ();
+}
+
+/* { dg-final { scan-assembler "call\t35" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+
+ ret = __builtin_bpf_helper_get_current_uid_gid ();
+}
+
+/* { dg-final { scan-assembler "call\t15" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_get_hash_recalc (skb);
+}
+
+/* { dg-final { scan-assembler "call\t34" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret, *sk;
+
+ ret = __builtin_bpf_helper_get_listener_sock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t98" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret, *map;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_get_local_storage (map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t81" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+
+ ret = __builtin_bpf_helper_get_numa_node_id ();
+}
+
+/* { dg-final { scan-assembler "call\t42" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+
+ ret = __builtin_bpf_helper_get_prandom_u32 ();
+}
+
+/* { dg-final { scan-assembler "call\t7" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_get_route_realm (skb);
+}
+
+/* { dg-final { scan-assembler "call\t24" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+
+ ret = __builtin_bpf_helper_get_smp_processor_id ();
+}
+
+/* { dg-final { scan-assembler "call\t8" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_get_socket_cookie (skb);
+}
+
+/* { dg-final { scan-assembler "call\t46" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_get_socket_uid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t47" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *regs, *buf;
+ uint32_t size;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_get_stack (regs, buf, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t67" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *map;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_get_stackid (ctx, map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t27" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *bpf_socket;
+ int level, optname, optlen;
+ char *optval;
+
+ ret = __builtin_bpf_helper_getsockopt (bpf_socket, level,
+ optname, optval, optlen);
+}
+
+/* { dg-final { scan-assembler "call\t57" } } */
new file mode 100644
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+ ret = __builtin_bpf_helper_ktime_get_ns ();
+}
+
+/* { dg-final { scan-assembler "call\t5" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t offset;
+ uint64_t from, to, size;
+
+ ret = __builtin_bpf_helper_l3_csum_replace (skb, offset, from, to, size);
+}
+
+/* { dg-final { scan-assembler "call\t10" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t offset;
+ uint64_t from, to, size;
+
+ ret = __builtin_bpf_helper_l4_csum_replace (skb, offset, from, to, size);
+}
+
+/* { dg-final { scan-assembler "call\t11" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *hdr;
+ uint32_t type, len;
+
+ ret = __builtin_bpf_helper_lwt_push_encap (skb, type, hdr, len);
+}
+
+/* { dg-final { scan-assembler "call\t73" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *param;
+ uint32_t action, param_len;
+
+ ret = __builtin_bpf_helper_lwt_seg6_action (skb, action,
+ param, param_len);
+}
+
+/* { dg-final { scan-assembler "call\t76" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t offset, delta;
+
+ ret = __builtin_bpf_helper_lwt_seg6_adjust_srh (skb, offset,
+ delta);
+}
+
+/* { dg-final { scan-assembler "call\t75" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *from;
+ uint32_t offset, len;
+
+ ret = __builtin_bpf_helper_lwt_seg6_store_bytes (skb, offset,
+ from, len);
+}
+
+/* { dg-final { scan-assembler "call\t74" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+ char *key = 0;
+
+ ret = __builtin_bpf_helper_map_delete_elem (map (), key);
+}
+
+/* { dg-final { scan-assembler "call\t3" } } */
new file mode 100644
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ char *key = 0, *value = 0;
+ value = __builtin_bpf_helper_map_lookup_elem (map (), key);
+}
+
+/* { dg-final { scan-assembler "call\t1" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+ char *value = 0;
+
+ ret = __builtin_bpf_helper_map_peek_elem (map (), value);
+}
+
+/* { dg-final { scan-assembler "call\t89" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+ char *value = 0;
+
+ ret = __builtin_bpf_helper_map_pop_elem (map (), value);
+}
+
+/* { dg-final { scan-assembler "call\t88" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+ char *value = 0;
+ long long flags = 0;
+
+ ret = __builtin_bpf_helper_map_push_elem (map (), value, flags);
+}
+
+/* { dg-final { scan-assembler "call\t87" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+ long long flags = 0;
+ char *key = 0, *value = 0;
+
+ ret = __builtin_bpf_helper_map_update_elem (map (), key, value, flags);
+}
+
+/* { dg-final { scan-assembler "call\t2" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *msg;
+ uint32_t bytes;
+
+ ret = __builtin_bpf_helper_msg_apply_bytes (msg, bytes);
+}
+
+/* { dg-final { scan-assembler "call\t61" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *msg;
+ uint32_t bytes;
+
+ ret = __builtin_bpf_helper_msg_cork_bytes (msg, bytes);
+}
+
+/* { dg-final { scan-assembler "call\t62" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t start, pop;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_msg_pop_data (skb, start, pop, flags);
+}
+
+/* { dg-final { scan-assembler "call\t91" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *msg;
+ uint32_t start, end;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_msg_pull_data (msg, start, end, flags);
+}
+
+/* { dg-final { scan-assembler "call\t63" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t start, len;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_msg_push_data (skb, start, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t90" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *msg, *map, *key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_msg_redirect_hash (msg, map, key,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t71" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *msg, *map;
+ uint64_t key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_msg_redirect_map (msg, map, key,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t60" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *regs;
+ uint64_t rc;
+
+ ret = __builtin_bpf_helper_override_return (regs, rc);
+}
+
+/* { dg-final { scan-assembler "call\t58" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *map;
+ uint64_t flags;
+ void *data;
+ uint64_t size;
+
+ ret = __builtin_bpf_helper_perf_event_output (ctx, map, flags, data, size);
+}
+
+/* { dg-final { scan-assembler "call\t25" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *map, *buf;
+ uint64_t flags;
+ uint64_t buf_size;
+
+ ret = __builtin_bpf_helper_perf_event_read_value (map, flags, buf, buf_size);
+}
+
+/* { dg-final { scan-assembler "call\t55" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+ void *map;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_perf_event_read (map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t22" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *buf;
+ uint64_t buf_size;
+
+ ret = __builtin_bpf_helper_perf_prog_read_value (ctx, buf, buf_size);
+}
+
+/* { dg-final { scan-assembler "call\t56" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ int size;
+ void *dst;
+ const void *unsafe_ptr;
+
+ ret = __builtin_bpf_helper_probe_read_str (dst, size, unsafe_ptr);
+}
+
+/* { dg-final { scan-assembler "call\t45" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *src, *dst;
+ uint32_t size;
+
+ ret = __builtin_bpf_helper_probe_read (dst, size, src);
+}
+
+/* { dg-final { scan-assembler "call\t4" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *dst, *src;
+ uint32_t len;
+
+ ret = __builtin_bpf_helper_probe_write_user (dst, src, len);
+}
+
+/* { dg-final { scan-assembler "call\t36" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx;
+ uint32_t protocol, toggle;
+ uint64_t scancode;
+
+ ret = __builtin_bpf_helper_rc_keydown (ctx, protocol,
+ scancode, toggle);
+}
+
+/* { dg-final { scan-assembler "call\t78" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx;
+ int32_t rel_x, rel_y;
+
+ ret = __builtin_bpf_helper_rc_pointer_rel (ctx, rel_x, rel_y);
+}
+
+/* { dg-final { scan-assembler "call\t92" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx;
+
+ ret = __builtin_bpf_helper_rc_repeat (ctx);
+}
+
+/* { dg-final { scan-assembler "call\t77" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *map;
+ uint32_t key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_redirect_map (map, key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t51" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *skb;
+
+ __builtin_bpf_helper_set_hash_invalid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t41" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint32_t ret;
+ void *skb;
+ uint32_t hash;
+
+ ret = __builtin_bpf_helper_set_hash (skb, hash);
+}
+
+/* { dg-final { scan-assembler "call\t48" } } */
new file mode 100644
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *bpf_socket;
+ int level;
+ int optname;
+ void *optval;
+ int optlen;
+
+ ret = __builtin_bpf_helper_setsockopt (bpf_socket, level, optname,
+ optval, optlen);
+}
+
+/* { dg-final { scan-assembler "call\t49" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret, *sk;
+
+ ret = __builtin_bpf_helper_sk_fullsock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t95" } } */
new file mode 100644
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret;
+ void *ctx, *tuple;
+ uint32_t tuple_size;
+ uint64_t netns, flags;
+
+ ret = __builtin_bpf_helper_sk_lookup_tcp (ctx,
+ tuple,
+ tuple_size,
+ netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t84" } } */
new file mode 100644
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret;
+ void *ctx, *tuple;
+ uint32_t tuple_size;
+ uint64_t netns, flags;
+
+ ret = __builtin_bpf_helper_sk_lookup_udp (ctx,
+ tuple,
+ tuple_size,
+ netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t85" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *map, *key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sk_redirect_hash (skb, map, key,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t72" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *map;
+ uint32_t key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sk_redirect_map (ctx, map, key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t52" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *sock;
+
+ ret = __builtin_bpf_helper_sk_release (sock);
+}
+
+/* { dg-final { scan-assembler "call\t86" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *reuse, *map, *key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sk_select_reuseport (reuse, map,
+ key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t82" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *map, *sk;
+
+ ret = __builtin_bpf_helper_sk_storage_delete (map, sk);
+}
+
+/* { dg-final { scan-assembler "call\t108" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret;
+ void *map, *sk, *value;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sk_storage_get (map, sk, value,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t107" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ int32_t len_diff;
+ uint32_t mode;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_adjust_room (skb, len_diff, mode, flags);
+}
+
+/* { dg-final { scan-assembler "call\t50" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ uint64_t ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_skb_cgroup_id (skb);
+}
+
+/* { dg-final { scan-assembler "call\t79" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t len;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_change_head (skb, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t43" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ int16_t proto;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_change_proto (skb, proto, flags);
+}
+
+/* { dg-final { scan-assembler "call\t31" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t len;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_change_tail (skb, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t38" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t type;
+
+ ret = __builtin_bpf_helper_skb_change_type (skb, type);
+}
+
+/* { dg-final { scan-assembler "call\t32" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_skb_ecn_set_ce (skb);
+}
+
+/* { dg-final { scan-assembler "call\t97" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *key;
+ uint32_t size;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_get_tunnel_key (skb, key, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t20" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint8_t *opt;
+ uint32_t size;
+
+ ret = __builtin_bpf_helper_skb_get_tunnel_opt (skb, opt, size);
+}
+
+/* { dg-final { scan-assembler "call\t29" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *xfrm_state;
+ uint32_t index, size;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_get_xfrm_state (skb, index,
+ xfrm_state, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t66" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *to;
+ uint32_t offset, len, start_header;
+
+ ret = __builtin_bpf_helper_skb_load_bytes_relative (skb, offset,
+ to, len,
+ start_header);
+}
+
+/* { dg-final { scan-assembler "call\t68" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *to;
+ uint32_t offset, len;
+
+ ret = __builtin_bpf_helper_skb_load_bytes (skb, offset, to, len);
+}
+
+/* { dg-final { scan-assembler "call\t26" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t len;
+
+ ret = __builtin_bpf_helper_skb_pull_data (skb, len);
+}
+
+/* { dg-final { scan-assembler "call\t39" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *key;
+ uint32_t size;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_set_tunnel_key (skb, key, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t21" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint8_t *opt;
+ uint32_t size;
+
+ ret = __builtin_bpf_helper_skb_set_tunnel_opt (skb, opt, size);
+}
+
+/* { dg-final { scan-assembler "call\t30" } } */
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ uint32_t offset;
+ void *from;
+ uint32_t len;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_skb_store_bytes (skb, offset, from, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t9" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb, *map;
+ uint32_t index;
+
+ ret = __builtin_bpf_helper_skb_under_cgroup (skb, map, index);
+}
+
+/* { dg-final { scan-assembler "call\t33" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+
+ ret = __builtin_bpf_helper_skb_vlan_pop (skb);
+}
+
+/* { dg-final { scan-assembler "call\t19" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ int16_t vlan_proto;
+ uint16_t vlan_tci;
+
+ ret = __builtin_bpf_helper_skb_vlan_push (skb, vlan_proto, vlan_tci);
+}
+
+/* { dg-final { scan-assembler "call\t18" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret;
+ void *ctx, *tuple;
+ uint32_t tuple_size;
+ uint64_t netns, flags;
+
+ ret = __builtin_bpf_helper_skc_lookup_tcp (ctx, tuple,
+ tuple_size, netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t99" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skops, *map, *key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sock_hash_update (skops, map, key,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t70" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skops, *map, *key;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sock_map_update (skops, map, key,
+ flags);
+}
+
+/* { dg-final { scan-assembler "call\t53" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *bpf_sock;
+ int argval;
+
+ ret = __builtin_bpf_helper_sock_ops_cb_flags_set (bpf_sock,
+ argval);
+}
+
+/* { dg-final { scan-assembler "call\t59" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *lock;
+
+ __builtin_bpf_helper_spin_lock (lock);
+}
+
+/* { dg-final { scan-assembler "call\t93" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *lock;
+
+ __builtin_bpf_helper_spin_unlock (lock);
+}
+
+/* { dg-final { scan-assembler "call\t94" } } */
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *buf;
+ long res;
+ uint64_t flags;
+ size_t buf_len;
+
+ ret = __builtin_bpf_helper_strtol (buf, buf_len, flags, &res);
+}
+
+/* { dg-final { scan-assembler "call\t105" } } */
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *buf;
+ unsigned long res;
+ uint64_t flags;
+ size_t buf_len;
+
+ ret = __builtin_bpf_helper_strtoul (buf, buf_len, flags, &res);
+}
+
+/* { dg-final { scan-assembler "call\t106" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *buf;
+ size_t buf_len;
+
+ ret = __builtin_bpf_helper_sysctl_get_current_value (ctx, buf,
+ buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t102" } } */
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *buf;
+ size_t buf_len;
+ uint64_t flags;
+
+ ret = __builtin_bpf_helper_sysctl_get_name (ctx, buf,
+ buf_len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t101" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *buf;
+ size_t buf_len;
+
+ ret = __builtin_bpf_helper_sysctl_get_new_value (ctx, buf,
+ buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t103" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+ int ret;
+ void *ctx, *buf;
+ size_t buf_len;
+
+ ret = __builtin_bpf_helper_sysctl_set_new_value (ctx, buf,
+ buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t104" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ctx, *prog_array_map;
+ uint32_t index;
+
+ __builtin_bpf_helper_tail_call (ctx, prog_array_map, index);
+}
+
+/* { dg-final { scan-assembler "call\t12" } } */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *sk, *iph, *th;
+ uint32_t iph_len, th_len;
+
+ ret = __builtin_bpf_helper_tcp_check_syncookie (sk, iph,
+ iph_len,
+ th, th_len);
+}
+
+/* { dg-final { scan-assembler "call\t100" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ void *ret, *sk;
+
+ ret = __builtin_bpf_helper_tcp_sock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t96" } } */
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+ int ret;
+
+ ret = __builtin_bpf_helper_trace_printk ("foo %d %d", sizeof ("foo %d %d"), 10, 20);
+}
+
+/* { dg-final { scan-assembler "call\t6" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *xdp_md;
+ int delta;
+
+ ret = __builtin_bpf_helper_xdp_adjust_head (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t44" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *xdp_md;
+ int delta;
+
+ ret = __builtin_bpf_helper_xdp_adjust_meta (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t54" } } */
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *xdp_md;
+ int delta;
+
+ ret = __builtin_bpf_helper_xdp_adjust_tail (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t65" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+ int ret;
+ void *skb;
+ int ancestor_level;
+
+ ret = __builtin_bpf_helper_skb_ancestor_cgroup_id (skb,
+ ancestor_level);
+}
+
+/* { dg-final { scan-assembler "call\t83" } } */
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+long delta;
+long *val;
+
+void
+foo ()
+{
+ __sync_fetch_and_add(val, delta);
+ __sync_fetch_and_add((int *)val, (int)delta);
+}
+
+/* { dg-final { scan-assembler "xadddw\t.*" } } */
+/* { dg-final { scan-assembler "xaddw\t.*" } } */