18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (c) 2019 Facebook
38c2ecf20Sopenharmony_ci#define STACK_MAX_LEN 180
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* llvm upstream commit at clang18
68c2ecf20Sopenharmony_ci *   https://github.com/llvm/llvm-project/commit/1a2e77cf9e11dbf56b5720c607313a566eebb16e
78c2ecf20Sopenharmony_ci * changed inlining behavior and caused compilation failure as some branch
88c2ecf20Sopenharmony_ci * target distance exceeded 16bit representation which is the maximum for
98c2ecf20Sopenharmony_ci * cpu v1/v2/v3. Macro __BPF_CPU_VERSION__ is later implemented in clang18
108c2ecf20Sopenharmony_ci * to specify which cpu version is used for compilation. So a smaller
118c2ecf20Sopenharmony_ci * unroll_count can be set if __BPF_CPU_VERSION__ is less than 4, which
128c2ecf20Sopenharmony_ci * reduced some branch target distances and resolved the compilation failure.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * To capture the case where a developer/ci uses clang18 but the corresponding
158c2ecf20Sopenharmony_ci * repo checkpoint does not have __BPF_CPU_VERSION__, a smaller unroll_count
168c2ecf20Sopenharmony_ci * will be set as well to prevent potential compilation failures.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#ifdef __BPF_CPU_VERSION__
198c2ecf20Sopenharmony_ci#if __BPF_CPU_VERSION__ < 4
208c2ecf20Sopenharmony_ci#define UNROLL_COUNT 90
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci#elif __clang_major__ == 18
238c2ecf20Sopenharmony_ci#define UNROLL_COUNT 90
248c2ecf20Sopenharmony_ci#endif
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "pyperf.h"
27