Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 94 2012-2013 Microchip Technology Inc.
5.7.6 Options for Controlling Optimization
The following options control compiler optimizations. Optimization levels available depend
on the compiler edition (see Chapter 18. Optimizations.)
The following options control specific optimizations. The -O2 option turns on all of
these optimizations except -funroll-loops, -funroll-all-loops and -fst-
rict-aliasing.
-save-temps Dont delete intermediate files. Place them in the current directory and name
them based on the source file. Thus, compiling foo.c with -c
-save-temps would produce the following files:
foo.i (preprocessed file)
foo.p (pre procedure abstraction assembly language file)
foo.s (assembly language file)
foo.o (object file)
TABLE 5-11: GENERAL OPTIMIZATION OPTIONS
Option Edition Definition
-O0 All Do not optimize. (This is the default.)
Without -O, the compilers goal is to reduce the cost of compilation
and to make debugging produce the expected results. Statements
are independent: if you stop the program with a breakpoint between
statements, you can then assign a new value to any variable or
change the program counter to any other statement in the function
and get exactly the results you would expect from the source code.
The compiler only allocates variables declared register in regis-
ters.
-O
-O1
All Optimize. Optimizing compilation takes somewhat longer, and a lot
more host memory for a large function.
With -O, the compiler tries to reduce code size and execution time.
When -O is specified, the compiler turns on -fthread-jumps and
-fdefer-pop. The compiler turns on -fomit-frame-pointer.
-O2 STD, PRO Optimize even more. The compiler performs nearly all supported
optimizations that do not involve a space-speed trade-off. -O2 turns
on all optional optimizations except for loop unrolling (-fun-
roll-loops), function inlining (-finline-functions), and strict
aliasing optimizations (-fstrict-aliasing). It also turns on
Frame Pointer elimination (-fomit-frame-pointer). As com-
pared to -O, this option increases both compilation time and the
performance of the generated code.
-O3 PRO Optimize for speed. -O3 turns on all optimizations specified by -O2
and also turns on the inline-functions option.
-Os PRO Optimize for size. -Os enables all -O2 optimizations that do not typi-
cally increase code size. It also performs further optimizations
designed to reduce code size.
TABLE 5-10: DEBUGGING OPTIONS (CONTINUED)
Option Definition
Protego_Release_01_05-Related-OEM-Documentation-MPLAB-XC16-C-Compiler.pdf