Tail call optimization in cortex-m0+
How does tail call optimization work in cortex-m0+?
(Tail call optimization work in cortex-m3.)
$ cat test.c:
int i = 0;
void f() { i++; return; }
void call_f() { return f(); }
$ arm-none-eabi-gcc -Os -S -mcpu=cortex-m0plus -mthumb test.c -o test_m0.s
$ arm-none-eabi-gcc -Os -S -mcpu=cortex-m3 -mthumb test.c -o test_m3.s
$ cat test_m0.s
...
call_f:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
push {r4, lr}
bl f
@ sp needed
pop {r4, pc}
$ cat test_m3.s
...
call_f:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
b f
gcc version:
arm-none-
Question information
- Language:
- English Edit question
- Status:
- Expired
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: