162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci// Copyright (c) 2019 Facebook
362306a36Sopenharmony_ci#define STACK_MAX_LEN 180
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/* llvm upstream commit at clang18
662306a36Sopenharmony_ci *   https://github.com/llvm/llvm-project/commit/1a2e77cf9e11dbf56b5720c607313a566eebb16e
762306a36Sopenharmony_ci * changed inlining behavior and caused compilation failure as some branch
862306a36Sopenharmony_ci * target distance exceeded 16bit representation which is the maximum for
962306a36Sopenharmony_ci * cpu v1/v2/v3. Macro __BPF_CPU_VERSION__ is later implemented in clang18
1062306a36Sopenharmony_ci * to specify which cpu version is used for compilation. So a smaller
1162306a36Sopenharmony_ci * unroll_count can be set if __BPF_CPU_VERSION__ is less than 4, which
1262306a36Sopenharmony_ci * reduced some branch target distances and resolved the compilation failure.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * To capture the case where a developer/ci uses clang18 but the corresponding
1562306a36Sopenharmony_ci * repo checkpoint does not have __BPF_CPU_VERSION__, a smaller unroll_count
1662306a36Sopenharmony_ci * will be set as well to prevent potential compilation failures.
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci#ifdef __BPF_CPU_VERSION__
1962306a36Sopenharmony_ci#if __BPF_CPU_VERSION__ < 4
2062306a36Sopenharmony_ci#define UNROLL_COUNT 90
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci#elif __clang_major__ == 18
2362306a36Sopenharmony_ci#define UNROLL_COUNT 90
2462306a36Sopenharmony_ci#endif
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#include "pyperf.h"
27