4.6.6.9 Local Option
The -flocal
option limits the extent to which some
optimizations are applied to the program.
This option will use omniscient code generation (OCG) optimizations with libraries or individual program modules but have the scope of those optimizations restricted to code within those libraries or modules. Normally optimizations in one module can be affected by code in other modules or libraries, and there are situations where you want to prevent this from occurring. The output of source compiled with this setting enabled with typically be larger but will change little from build to build, even if other project code that does not use this setting is modified. Such changes in the output might be undesirable if you have validated code that is to be distributed and used in many different applications.
All the source code specified with a build command that uses local optimizations constitutes one group and you can create as many groups as required by building source code with separate build commands. Any code built without local optimizations becomes part of the default (unrestricted) group. The standard libraries that are supplied with the compiler are built with local optimizations disabled and are always part of this default group.
Enabling local optimizations restricts the scope of many optimizations, but does not necessarily disable the optimizations themselves. Optimizations can still be performed within each group, but those optimizations will not be made if they depend on code that is contained in another group. For example, abstraction of common code sequences will not be made if the sequences are contained in different groups, but would be made if the sequences are from the same group. Since a group can be limited to just a few modules of source code (which you can build into a library in the usual way if you prefer), this still allows you to fully optimize the bulk of a project.
By default this option is disabled. It can be enabled when building for enhanced mid-range and PIC18 devices and an error message will be emitted if the optimization is selected with an incompatible device.
When code is built with local optimizations, all variables defined in that
group are allocated to banked memory unless they are qualified with near. Bank selection
instructions are often output when they might normally have been emitted. Page selection
instructions before and after function calls are always output, constant propagation is
disabled, floating-point type sizes are fixed at 32 bits for both float
and double
types (and this will be enforced for the entire program) and
pointer sizes can be fixed based on their definition (see 5.3.6.2 Pointer-target Qualifiers). Some assembly
optimizations are also restricted, such as procedural abstraction, routine inlining, psect
merging, and peephole optimizations.