<div dir="ltr"><div>Thanks Tim & Peter,</div><div><br></div><div>I am referring to mpi_montmul function from library/bignum.c, and this problem only occurs at clang -O3, so for the moment I am compiling the library with clang -02.</div><div><br></div><div>As for GCC, if -fno-omit-frame-pointer is NOT used, it doesn't use r7 as frame register, while clang uses r7 by default (even without -fno-omit-frame-pointer).</div><div><br></div><div>So my question is how to turn the use of frame pointer off for clang/llc?</div><div><br></div><div><div><div dir="ltr" class="m_8641623894300424039gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Son Tuan Vu</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 21, 2019 at 11:18 AM Peter Smith <<a href="mailto:peter.smith@linaro.org" target="_blank">peter.smith@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 21 Aug 2019 at 06:05, Son Tuan VU via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hello all,<br>
><br>
> I noticed that for ARM Thumb target, llc uses r7 as frame pointer (gcc does not do this AFAIK), and this register should therefore not be used as a general-purpose register.<br>
><br>
> However, when compiling mbedTLS, which contains some code that is highly optimized for ARM platform and uses r7 to efficiently perform an operation. This raises an exception since r7 is now the frame pointer.<br>
><br>
> I tried passing -fomit-frame-pointer but this is just a hacky workaround and does not work in this case, since the function here does indeed need frame pointer.<br>
> ```<br>
> The -fomit-frame-pointer option instructs the compiler to not store stack frame pointers if the function does not need it. You can use this option to reduce the code image size.<br>
> ```<br>
<br>
Can you let us know which function in mbedTLS you are referring to. I<br>
found <a href="https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here" rel="noreferrer" target="_blank">https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here</a><br>
on the mbedTLS website which implies that you should use<br>
-fomit-frame-pointer. I would be very surprised for code in mbedTLS to<br>
simultaneously require a frame pointer and reserve r7 in Thumb state.<br>
There may be some confusion about what GCC does as arm-none-eabi-gcc<br>
uses -fomit-frame-pointer by default. As Tim points out, I think<br>
you'll find that gcc will use r7 as the frame pointer if<br>
-fno-omit-frame-pointer is used.<br>
<br>
Peter<br>
<br>
><br>
> My question is, how can I instruct the register allocator to use another register as frame pointer, or at least turn off the use of frame pointer? I tried changing the ABI with -mabi and -meabi but nothing works so far.<br>
><br>
> Thanks a lot for your help,<br>
><br>
> Cheers,<br>
><br>
> Son Tuan Vu<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>