Optimize AArch64 code with LLVM LTO and PGO
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 LTO and PGO
Review 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.
You should have the
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.Try both. Each mode emits LLVM bitcode during compilation but performs link-time optimization differently. Use the documented commands to build each mode and compare the results.
Confirm that
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.FE-PGO writes counters to a path you provide with
-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.Check that your build invoked the appropriate LTO mode and included the profile-use option for your profile type, such as
-fprofile-sample-use for S-PGO. You can also inspect objects or binaries with LLVM tools to review emitted bitcode or profile-driven metadata.