Use the inline keyword or the command line option -Oi for C/C++ functions (see -Oi: Inlining for more information). Defining a function before using it helps the Compiler to inline it:
/* OK */ /* better! */
void myfun(void); void myfun(void) {
void main(void) { // ...
myfun(); }
} void main(void) {
void myfun(void) { myfun();
// ... }
}
This also allows the compiler to use a relative branch instruction instead of an absolute branch instruction.