In the manual for the XC16 compiler, it says the following:
The compiler will only eliminate inline functions if they are declared to be static and if the function definition precedes all uses of the function.
At the top of foo.c I declared
static inline void nop_10_times(void);
Then in the definition for an ISR defined as:
void _CNInterrupt(void)
{
nop_10_times();
// rest of function
}
Then, as a test, I put the definition to nop_10_times
at the bottom of the file.
static inline void nop_10_times(void)
{
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
__builtin_nop();
}
When I compile my project and look at the assembly, it seems that the compiler was, in fact, able to completely remove the function in assembly and only leave the inline code where it was called in the ISR.
Does anyone know how it was able to do this? According to the definition in the manual, it said it would eliminate the inline function if "the function definition precedes all uses of the function."