[Bug target/85593] GCC on ARM allocates R3 for local variable when calling naked function with O2 optimizations enabled
austinpmorton at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 1 19:19:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85593
--- Comment #2 from Austin Morton <austinpmorton at gmail dot com> ---
Where is this limitation documented? The GCC documentation on the naked
function attribute makes no mention of such a caveat:
https://gcc.gnu.org/onlinedocs/gcc/ARM-Function-Attributes.html
See here for real world usage that triggers this issue:
https://git.kernel.org/pub/scm/bluetooth/sbc.git/tree/sbc/sbc_primitives_armv6.c
Note that I am not the original author of the above code, just someone who ran
into issues attempting to use it on gcc newer than 4.x
In this specific case it is simple enough to fix by pushing r3, but it seemed
like a bug with the compiler, considering the behavior changed between major
releases.
If this is indeed an issue with the code itself and not the compiler, that is
fine, but it should certainly be documented that naked functions are not meant
to be called directly.
More information about the Gcc-bugs
mailing list