[llvm-dev] Custom calling convention & ARM target

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 17 23:44:49 PDT 2019


Hi,

On Wed, 17 Jul 2019 at 23:30, Alexander Mitin <amitin at instantiations.com> wrote:
> Now getting back to the problem, note that the handlers call to 'puts' so LR
> register gets changed.
> See https://gist.github.com/amitin/7df4fbb806c0b48eb5bcaf614e5d93cd#file-test-s-L31

Sure, but this is completely normal, ARM's BL instruction will
*always* change LR. If LLVM wasn't used to dealing with this issue
then no code would ever work on ARM.

What normally happens is that the call gets marked as clobbering LR
which triggers ARMFrameLowering.cpp to save it in the prologue and
restore it in the epilogue.

You mention above that you've patterned your changes on the GHC
convention, which suppresses prologue and epilogue. That's probably
where I'd start to look for the problem. But don't trust what's there
already: I'm not sure how functional the GHC convention is on ARM, it
seems like it could only work if it guaranteed *every* call was a tail
call.

> The same IR code works fine for x86_64. You can verify it by changing
> the triple to x86_64 (uncomment the test.ll:5 line and comment
> test.ll:4 then compile it with llc).

x86_64 has a completely different call/return sequence that
automatically involves the stack so that's not surprising.

Cheers.

Tim.


More information about the llvm-dev mailing list