xref: /linux/tools/testing/selftests/bpf/progs/pyperf180.c (revision 2d7f3d1a5866705be2393150e1ffdf67030ab88d)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 #define STACK_MAX_LEN 180
4 
5 /* llvm upstream commit at clang18
6  *   https://github.com/llvm/llvm-project/commit/1a2e77cf9e11dbf56b5720c607313a566eebb16e
7  * changed inlining behavior and caused compilation failure as some branch
8  * target distance exceeded 16bit representation which is the maximum for
9  * cpu v1/v2/v3. Macro __BPF_CPU_VERSION__ is later implemented in clang18
10  * to specify which cpu version is used for compilation. So a smaller
11  * unroll_count can be set if __BPF_CPU_VERSION__ is less than 4, which
12  * reduced some branch target distances and resolved the compilation failure.
13  *
14  * To capture the case where a developer/ci uses clang18 but the corresponding
15  * repo checkpoint does not have __BPF_CPU_VERSION__, a smaller unroll_count
16  * will be set as well to prevent potential compilation failures.
17  */
18 #ifdef __BPF_CPU_VERSION__
19 #if __BPF_CPU_VERSION__ < 4
20 #define UNROLL_COUNT 90
21 #endif
22 #elif __clang_major__ == 18
23 #define UNROLL_COUNT 90
24 #endif
25 
26 #include "pyperf.h"
27