Tail call optimization in cortex-m0+

Asked by Junichi Kimura

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-eabi-gcc.exe (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496]

Question information

Language:
English Edit question
Status:
Expired
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.