In some architectures (for example, x86, x86_64), the return address of the function is always stored on the stack, and calling the function implies access to the main memory:
In contrast, if your architecture / ABI can jump / return without using the main memory, and the parameters and returned values ββof the called party can also be transferred to the registers, the call and return to / from the sheet functions can be performed without including main memory.
If the sheet function is simple enough, it can be performed without touching RAM:
int callee(int a, int b) { return a + b; } int caller(int a, int b, int c, int d) { return callee(a,b) + calle(c,d); }
gives (each function is compiled separately clang -target arm-eabi -S -o- -O3 ):
callee: add r0, r1, r0 bx lr caller: .save {r4, r5, r6, r10, r11, lr} push {r4, r5, r6, r10, r11, lr} .setfp r11, sp,
Note that we can avoid memory access in the caller core and in calee .