11.1. Benefits of Using LTO (2024)

  • »
  • tiarmclang Compiler User Manual »
  • 11. Link Time Optimization - LTO »
  • 11.1. Benefits of Using LTO - Enabling Inter-Module Optimizations

11.1.1. A Simple Example

Consider a simple example application that demonstrateis just one of the potential benefits of using LTO to enable inter-module optimization …

Suppose we have a series of source files in which many of the same string constants are referenced repeatedly and across multiple source files.

If we compile and link without LTO turned on:

%> tiarmclang -mcpu=cortex-m4 -Oz constant_merge_test.c ic_s10.c ic_s20.c ic_s30.c ic_s40.c s10.c s20.c s30.c s40.c -o no_lto.out -Wl,-llnk.cmd,-mno_lto.map

The linker generated map file, no_lto.map, reveals that the size of the .rodata section where all of the string constants are defined is reasonably large:

...SEGMENT ALLOCATION MAPrun origin load origin length init length attrs members---------- ----------- ---------- ----------- ----- -------00000020 00000020 00007a4c 00007a4c r-x 00000020 00000020 00004ad2 00004ad2 r-- .rodata ......

But if we then compile with LTO enabled:

%> tiarmclang -mcpu=cortex-m4 -flto -Oz constant_merge_test.c ic_s10.c ic_s20.c ic_s30.c ic_s40.c s10.c s20.c s30.c s40.c -o with_lto.out -Wl,-llnk.cmd,-mwith_lto.map

Then the map file, with_lto.map, shows that the .rodata output section is significantly smaller in the LTO-enabled build:

...SEGMENT ALLOCATION MAPrun origin load origin length init length attrs members---------- ----------- ---------- ----------- ----- -------00000020 00000020 00005b84 00005b84 r-x ... 00004530 00004530 00001674 00001674 r-- .rodata...

The use of LTO in this example enables the compiler to perform an inter-module constant merging optimization that results in a savings of 0x4ad2 - 0x1674 -> 0x345e (13406) bytes in the .rodata section. Note that in this example, the savings in the size of the .rodata section is offset somewhat by increased code size in other sections like .text. The net savings is 0x7a4c - 0x5b84 -> 0x1ec8 (7880) bytes.

11.1.2. Code Size Reduction Due to Use of LTO

Significant code size savings can be realized by simply enabling the LTO feature in the build of an application. Comparisons between compiler-generated code size over a collection of Cortex-M0+, Cortex-M4, and Cortex-R5 example applications demonstrated that building these applications with LTO enabled resulted in significant code size reductions versus building the applications without LTO enabled.

Table 1: Code Size Reduction Due to Use of LTO

TI Arm Processor

% Code Size Reduction

Example Applications (count)

Cortex-M0+

23-25%

M0+ Driver Libraries (191)

Cortex-M4

6-11%

M4 SDK Examples (362)

Cortex-R5

4-8%

EEMBC AutoBench (15)

  • % Code Size Reduction = (1-(LTO code size / non-LTO code size))*100

These code size measurements were taken over 568 Cortex-M0+, Cortex-M4, and Cortex-R5 example applications. All of these applications were compiled with the -Oz compiler option to prioritize code size reduction optimizations. The -flto compiler option was used to enable LTO.

11.1.3. Performance Improvement Due to Use of LTO

Enabling LTO during an application build can also provide significant speedup. With LTO enabled, example applications built on Cortex-M0+, Cortex-M4, and Cortex-R5 ran significantly faster than when the same applications were built without LTO enabled.

Table 2: Performance Improvement Due to Use of LTO

TI Arm Processor

Speedup Factor

% Reduction in Time/Cycles

Cortex-M0+

1.20

3.8%

Cortex-M4

1.12

4.4%

Cortex-R5

1.17

9.3%

  • Speedup Factor = (non-LTO cycles/LTO cycles)

  • % Reduction in Cycles = ((non-LTO cycles - LTO cycles)/non-LTO cycles)*100

The performance results shown here were derived from measurements over 15 EEMBC AutoBench applications running on Cortex-M0+, Cortex-M4, and Cortex-R5 hardware. For the Cortex-M0+ measurements, an application’s execution time was calculated using a SysTick interrupt service routine. For the Cortex-M4 and COrtex-R5 measurements, a simple cycle count for each application’s execution time was collected. All example applications were compiled with the -O3 compiler option to prioritize performance improvement optimizations. The -flto compiler option was used to enable LTO.

Note

Increased Function Inlining

Using LTO may result in increased function inlining, which may improve performance as well as code size generally but may result in larger stack frames. This may require the user to either increase the size of the of the stack or else prevent certain functions from being inlined that are known to require large stack frames.

To debug this, it is recommended that users use the CCS Stack View to see a view of the static stack usage of each function in the application. See Stack Usage View in CCS for more information. Using the Stack Usage View requires that source code be built with debug enabled. This features relies on the –call_graph capability provided by the tiarmofd Object File Display utility.

11.1. Benefits of Using LTO (2024)
Top Articles
Facebook & Instagram Feed VS Stories: Which Ones To Choose?
Do I Need Travel Insurance for Costa Rica? | Allianz Global Assistance
Nullreferenceexception 7 Days To Die
Craigslist Campers Greenville Sc
Katmoie
Blanchard St Denis Funeral Home Obituaries
877-668-5260 | 18776685260 - Robocaller Warning!
Women's Beauty Parlour Near Me
Ashlyn Peaks Bio
Barstool Sports Gif
Evita Role Wsj Crossword Clue
Was sind ACH-Routingnummern? | Stripe
Craigslist Alabama Montgomery
Scholarships | New Mexico State University
Classroom 6x: A Game Changer In The Educational Landscape
Where does insurance expense go in accounting?
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Nwi Arrests Lake County
979-200-6466
Epro Warrant Search
Lawson Uhs
Foxy Brown 2025
Beryl forecast to become an 'extremely dangerous' Category 4 hurricane
Acts 16 Nkjv
Drift Hunters - Play Unblocked Game Online
Skycurve Replacement Mat
Synergy Grand Rapids Public Schools
Nk 1399
Mini-Mental State Examination (MMSE) – Strokengine
Duke University Transcript Request
Busch Gardens Wait Times
LG UN90 65" 4K Smart UHD TV - 65UN9000AUJ | LG CA
Perry Inhofe Mansion
Duke Energy Anderson Operations Center
Gyeon Jahee
Roto-Rooter Plumbing and Drain Service hiring General Manager in Cincinnati Metropolitan Area | LinkedIn
House Of Budz Michigan
Directions To 401 East Chestnut Street Louisville Kentucky
Tugboat Information
Pp503063
Craigslist Free Manhattan
R: Getting Help with R
Booknet.com Contract Marriage 2
'The Nun II' Ending Explained: Does the Immortal Valak Die This Time?
How the Color Pink Influences Mood and Emotions: A Psychological Perspective
Terrell Buckley Net Worth
Is Chanel West Coast Pregnant Due Date
Great Clips Virginia Center Commons
Mkvcinemas Movies Free Download
Otter Bustr
Predator revo radial owners
La Fitness Oxford Valley Class Schedule
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 5731

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.