29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Compiler</strong> Coding Practices<br />

5.3 <strong>Compiler</strong> optimization levels and <strong>the</strong> debug view<br />

The precise optimizations per<strong>for</strong>med by <strong>the</strong> compiler depend both on <strong>the</strong> level of optimization<br />

chosen, and whe<strong>the</strong>r you are optimizing <strong>for</strong> per<strong>for</strong>mance or code size.<br />

The compiler supports <strong>the</strong> following optimization levels:<br />

-O0 Minimum optimization. The compiler per<strong>for</strong>ms simple optimizations that do not<br />

impair <strong>the</strong> debug view.<br />

When debugging is enabled, this option gives <strong>the</strong> best possible debug view.<br />

-O1 Restricted optimization.<br />

When debugging is enabled, this option gives a generally satisfactory debug view<br />

with good code density.<br />

-O2 High optimization. This is <strong>the</strong> default optimization level.<br />

When debugging is enabled, this option might give a less satisfactory debug view.<br />

-O3 Maximum optimization. This is <strong>the</strong> most aggressive <strong>for</strong>m of optimization<br />

available. Specifying this option enables multifile compilation by default where<br />

multiple files are specified on <strong>the</strong> command line.<br />

When debugging is enabled, this option typically gives a poor debug view.<br />

Because optimization affects <strong>the</strong> mapping of object code to source code, <strong>the</strong> choice of<br />

optimization level with -Ospace and -Otime generally impacts <strong>the</strong> debug view.<br />

The option -O0 is <strong>the</strong> best option to use if a simple debug view is needed. Selecting -O0 typically<br />

increases <strong>the</strong> size of <strong>the</strong> ELF image by 7 to 15%. To reduce <strong>the</strong> size of your debug tables, use<br />

<strong>the</strong> --remove_unneeded_entities option.<br />

5.3.1 See also<br />

Tasks<br />

• Methods of reducing debug in<strong>for</strong>mation in objects and libraries on page 5-20.<br />

Concepts<br />

• Benefits of reducing debug in<strong>for</strong>mation in objects and libraries on page 5-19.<br />

Reference<br />

<strong>Compiler</strong> Reference:<br />

• --debug, --no_debug on page 3-24<br />

• --debug_macros, --no_debug_macros on page 3-24<br />

• --dwarf2 on page 3-35<br />

• --dwarf3 on page 3-35<br />

• -Onum on page 3-71<br />

• -Ospace on page 3-72<br />

• -Otime on page 3-73<br />

• --remove_unneeded_entities, --no_remove_unneeded_entities on page 3-82.<br />

O<strong>the</strong>r in<strong>for</strong>mation<br />

• <strong>ARM</strong> ELF File Format,<br />

http://infocenter.arm.com/help/topic/com.arm.doc.dui0101-/index.html<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 5-7<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!