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