Optimize AArch64 code with LLVM link-time optimization and profile-guided optimization
Introduction
Understand PGO and LTO for AArch64 code
Prepare your AArch64 environment and verify LLVM tool availability
Build AArch64 code with LTO
Optimize AArch64 code with S-PGO
Optimize AArch64 code with FE-PGO
Optimize AArch64 code with IR-PGO
Optimize AArch64 code with CSIR-PGO
Next Steps
Optimize AArch64 code with LLVM link-time optimization and profile-guided optimization
Who is this for?
This is an introductory topic for developers who compile C or C++ applications on AArch64 Linux and want to use link-time optimization (LTO) with profile-guided optimization (PGO).
What will you learn?
Upon completion of this Learning Path, you will be able to:
- Understand how LTO and PGO guide LLVM optimizations.
- Build Full-LTO and Thin-LTO binaries with Clang on AArch64.
- Generate and inspect sample-based and instrumentation-based profiles.
- Use each profile type to build and run an optimized example application.
Prerequisites
Before starting, you will need the following:
- An AArch64 Linux system with LLVM installed. You need Clang, LLD,
llvm-bcanalyzer,llvm-profdata,llvm-profgen, andllvm-readelfin yourPATH. For setup instructions, see the LLVM toolchain for Linux on Arm install guide. - For the sample PGO workflow based on Branch Record Buffer Extension (BRBE), a processor that implements the BRBE, Linux kernel 6.17 or later, and Linux
perf. Other sample-based PGO workflows can use sources such as Statistical Profiling Extension (SPE) or Performance Monitoring Unit (PMU) events and have different requirements.
Summary
This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
perf. You’ll create frontend, IR-level, and context-sensitive profiles, merge and inspect profiles with LLVM tools, and apply each profile in optimized LTO builds.Frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
bsort.cpp source file and two directories: out for objects and binaries, and prof for raw and converted profile data. Keep these locations separate so you can distinguish build artifacts from profiling data.perf produced recording data that llvm-profgen can convert into an LLVM sample profile. If collection fails, check that your processor implements BRBE and that perf is available. You can use other sample sources, such as SPE or PMU events, with their own requirements.-fprofile-instr-generate, typically under the prof directory. After running the instrumented binary, use llvm-profdata to convert and inspect the profile data. Then, use that profile in your next optimized Clang build.-fprofile-sample-use for S-PGO. You can also inspect objects or binaries with LLVM tools to review emitted bitcode or profile-driven metadata.