3.4 Procedural Abstraction
Procedural Abstraction optimizations, not available with the AVR-GCC compiler, are utilized by MPLAB XC8, and the effect of these might break assumptions about where code is located.
Description
Procedural Abstraction is essentially a reverse inlining process and is performed on identical assembly code sequences that appear more than once. Identical code sequences are abstracted into a callable routine, and each instance of the original code sequence is replaced with a call to that routine. This optimization reduces code size considerably, but will impose a small reduction in execution speed. This optimization can, however, adversely impact debugging.
When using MPLAB XC8, Procedural Abstraction optimizations are automatically turned
on with level s
optimizations (-Os
). Any
abstracted assembly sequences will be placed in a separate section to the original
code. If there are linker options or linker scripts being used to locate code at
specific addresses, these might not correctly handle the sections containing the
abstracted code.
Migration
Procedural Abstraction optimizations can be turned off if they interfere with the
linking requirements of a project. Completely disable Procedural Abstraction for the
entire program using the -mno-pa
option. The content of individual
files or functions can be protected from Procedural Abstraction by using the
-mno-pa-on-file=filename
or
-mno-pa-on-function=function
options
respectively. There is also a nopa
attribute (or
__nopa
specifier) that can be used to disable Procedural
Abstraction for a particular function.