huojianchaoyy opened a new pull request, #22598: URL: https://github.com/apache/nuttx/pull/22598
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Profile-guided optimization (PGO) for Clang, from Xiaomi Vela. Second of four coverage PRs; it contains the commits of #22597, and only the last six commits are new here. depends-on: apache/nuttx/pull/22597 - **compiler-rt: add IR PGO support**: adds `CONFIG_COVERAGE_SOURCE` / `CONFIG_COVERAGE_PGO` under `CONFIG_COVERAGE_ALL`, the runtime that collects IR PGO data with `CONFIG_COVERAGE_MINI` and Clang (`profile_value.c`, `profile_write.c`), the `-fprofile-generate` / `-fprofile-use` options in the arch toolchain files, and Documentation/guides/pgo_instrumentation.rst. On qemu-armv8a CoreMark ran 16-20% faster with the profile. This one commit is about 1650 lines; most of it is the two new runtime files and the guide. The original change also touched the arm64 armclang toolchain, which is not upstream, so that hunk is left out. - **libgcc: split gcov.c**: moves the gcov structures to `gcov_internal.h` and the counter writers to `gcov_write.c`, so the GCC PGO runtime of the next PR can share them. No functional change. - **compiler-rt: use atomic operations**: updates the value profile counters atomically. Pre-existing and follow-up style fixes: **.codespell-ignore-lines: accept the GHS size file name** (the `*.siz` file named in `arch/arm/src/cmake/ghs.cmake`), **libs/libbuiltin/libgcc: add the SPDX identifier to the new gcov files**, and **libs/libbuiltin/compiler-rt: fix the nxstyle and codespell errors** of the new files. No functional change. ## Impact - New Kconfig choice under `CONFIG_COVERAGE_ALL`: `CONFIG_COVERAGE_SOURCE` (the default, the existing coverage instrumentation) or `CONFIG_COVERAGE_PGO`. Existing coverage configurations keep their behavior. - With `CONFIG_COVERAGE_PGO` and Clang, the build uses `-fprofile-use` when `default.profdata` exists in the build directory and `-fprofile-generate` otherwise. - New documentation: Documentation/guides/pgo_instrumentation.rst. ## Testing Host: Ubuntu 22.04 (Linux 6.8, x86_64), host GCC 13.4, aarch64-none-elf-gcc 13.4, arm-none-eabi-gcc 13.2.1, CMake 3.23 with Ninja. Base: master bec2b2a11e8. `./tools/checkpatch.sh -c -u -m -g HEAD~9..HEAD` passes. Each commit builds in these configurations (`CONFIG_COVERAGE_MINI=y`, `CONFIG_COVERAGE_ALL=y` unless noted): - `sim:nsh` (Make and CMake) - `qemu-armv8a:nsh` (CMake), `qemu-armv8a:nsh_smp` (Make), `qemu-armv8a:knsh` (Make) - `fvp-armv8r:pnsh` (Make) - `qemu-armv7r:pnsh` (Make, `CONFIG_COVERAGE_MINI` only, because the instrumented image does not fit in kflash) - `qemu-armv8a:nsh` without coverage (CMake) Not tested: running a Clang PGO build (no Clang cross toolchain for the qemu targets on this host), xtensa. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
