You copied the Doc URL to your clipboard.

ARM Compiler Software Development Guide : Optimizing across modules with link time optimization [ALPHA]

Optimizing across modules with link time optimization [ALPHA]

Additional optimization opportunities are available at link time, because source code from different modules can be optimized together.


This topic describes an [ALPHA] feature. See Support level definitions.

By default, the compiler optimizes each source module independently, translating C or C++ source code into an ELF file containing object code. At link time the linker combines all the ELF object files into an executable by resolving symbol references and relocations. Compiling each source file separately means the compiler might miss some optimization opportunities, such as cross-module inlining.

When link time optimization is enabled, the compiler translates source code into an intermediate form called bitcode. At link time, the linker collects all bitcode files together and sends them to the link time optimizer (llvm-lto) as one or more larger units. Collecting modules together means the link time optimizer can perform more optimizations because it has more information about the dependencies between modules. The link time optimizer then sends a single ELF object file back to the linker. Finally, the linker combines all object and library code to create an executable.

Figure 6-1 Link time optimization


Link Time Optimization performs aggressive optimizations. Sometimes this can result in large chunks of code being removed.


Bitcode files and ELF object files both have the default extension .o. You can use armclang -c -o filename to specify a different filename and extension for bitcode files, for example .bc.

This section contains the following subsections: