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
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?
After completing this Learning Path, you'll be able to perform the following tasks:
- 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'll need the following prerequisites:
- 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.
You’ll combine LLVM LTO with PGO to guide Clang optimization of an AArch64 C++ application on Linux. First, you’ll prepare the toolchain and example. Then, you’ll build Full-LTO and Thin-LTO variants and collect sample profiles with
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.