Open k15tfu opened 2 years ago
@llvm/issue-subscribers-backend-arm
Could you please try main
branch? 11 is too old.
This is the same with main
(b94ea8b3ebc16504b668fd7086de544637e0cd53
).
I believe this is expected behaviour. I see the same thing happen with GCC. If we look at the docs for naked
(https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html):
The only statements that can be safely included in naked functions are asm statements that do not have operands.
Arm Compiler For Embedded (aka Arm Compiler 6), which uses clang, also says the same thing (https://developer.arm.com/documentation/101754/0618/armclang-Reference/Compiler-specific-Function--Variable--and-Type-Attributes/--attribute----naked---function-attribute):
The compiler only supports basic __asm statements in __attribute__((naked)) functions. Using extended assembly, parameter references or mixing C code with __asm statements might not work reliably.
If you want to guarantee the output you'll have to recreate what the PIC code would do but in inline asm. Or you could lift the parts before the memory barrier into the callers, if all you care about is having the compiler generated instructions go after the memory barrier.
Hi!
Compile the following code with
-O2 -fPIC -march=armv7-a -mthumb
:Output:
armv7-a clang 11.0.1 https://godbolt.org/z/d9dMndvsj