5.7.1.19 No-hi-addr-opt Option

The -mno-hi-addr-opt option disables certain optimizations associated with the access of special function registers (SFRs).

The employs a SFR Access Efficiency feature, which adds the address attribute to peripheral SFRs defined in the processor header file. Compiler optimizations use this information to reduce the number of registers required to access multiple SFRs from within a single function and to remove redundant load instructions. This feature is enabled by default at optimization levels -O2, -Os, and -O3.

If you are building a static library that accesses an SFR and you want that same prebuilt library to work across devices that may have the SFRs located at a different address (for example, the TMR1 SFR object is located at different addresses on different devices), compile your library with the -mno-hi-addr-opt option. This will result in larger code, but the SFR address will be determined at link time.