kernel_samsung_a53x/tools/testing/selftests
Yonghong Song 2416f624ce selftests/bpf: Fix pyperf180 compilation failure with clang18
[ Upstream commit 100888fb6d8a185866b1520031ee7e3182b173de ]

With latest clang18 (main branch of llvm-project repo), when building bpf selftests,
    [~/work/bpf-next (master)]$ make -C tools/testing/selftests/bpf LLVM=1 -j

The following compilation error happens:
    fatal error: error in backend: Branch target out of insn range
    ...
    Stack dump:
    0.      Program arguments: clang -g -Wall -Werror -D__TARGET_ARCH_x86 -mlittle-endian
      -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include
      -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf -I/home/yhs/work/bpf-next/tools/include/uapi
      -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include -idirafter
      /home/yhs/work/llvm-project/llvm/build.18/install/lib/clang/18/include -idirafter /usr/local/include
      -idirafter /usr/include -Wno-compare-distinct-pointer-types -DENABLE_ATOMICS_TESTS -O2 --target=bpf
      -c progs/pyperf180.c -mcpu=v3 -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/pyperf180.bpf.o
    1.      <eof> parser at end of file
    2.      Code generation
    ...

The compilation failure only happens to cpu=v2 and cpu=v3. cpu=v4 is okay
since cpu=v4 supports 32-bit branch target offset.

The above failure is due to upstream llvm patch [1] where some inlining behavior
are changed in clang18.

To workaround the issue, previously all 180 loop iterations are fully unrolled.
The bpf macro __BPF_CPU_VERSION__ (implemented in clang18 recently) is used to avoid
unrolling changes if cpu=v4. If __BPF_CPU_VERSION__ is not available and the
compiler is clang18, the unrollng amount is unconditionally reduced.

  [1] 1a2e77cf9e

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20231110193644.3130906-1-yonghong.song@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-18 12:13:11 +01:00
..
android Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm64 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bpf selftests/bpf: Fix pyperf180 compilation failure with clang18 2024-11-18 12:13:11 +01:00
breakpoints Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
capabilities Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cgroup Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clone3 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
core Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpu-hotplug Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpufreq Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
damon Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dmabuf-heaps Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drivers selftests: netdevsim: fix the udp_tunnel_nic test 2024-11-18 12:13:01 +01:00
efivarfs selftests/efivarfs: create-read: fix a resource leak 2024-11-18 11:43:13 +01:00
exec Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
filesystems Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
firmware Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fpu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftrace selftests/ftrace: Add new test case which checks non unique symbol 2024-11-18 10:58:28 +01:00
futex Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gpio Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ia64 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_pstate Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ir Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kcmp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kexec Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kmod Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
livepatch Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lkdtm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
locking Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
media_tests Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
membarrier Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
memfd Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
memory-hotplug Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mincore Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mount Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mqueue Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net selftests/net: fix grep checking for fib_nexthop_multiprefix 2024-11-18 12:12:36 +01:00
netfilter Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsfs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ntb Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
openat2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pid_namespace Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pidfd selftests/pidfd: Fix ksft print formats 2024-11-18 11:43:02 +01:00
powerpc selftests/powerpc: Fix error handling in FPU/VMX preemption tests 2024-11-18 12:12:20 +01:00
prctl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
proc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pstore Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptrace Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rcutorture Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
resctrl selftests/resctrl: Ensure the benchmark commands fits to its array 2024-11-18 11:43:02 +01:00
rseq Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
safesetid Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
seccomp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sigaltstack Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
size Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sparc64 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
splice Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
static_keys Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sync Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysctl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tc-testing Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timens Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timers Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tmpfs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tpm2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uevent Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vDSO Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vm selftests/mm: fix awk usage in charge_reserved_hugetlb.sh and hugetlb_reparenting_test.sh that may cause error 2024-11-08 11:26:12 +01:00
watchdog Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wireguard Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
x86 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zram Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen_kselftest_tar.sh Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest_deps.sh Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest_harness.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest_install.sh Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kselftest_module.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib.mk Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
run_kselftest.sh Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00