[llvm-dev] How to correctly caller-save return address register

Dominik Montada via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 19 05:50:12 PDT 2021


Hi,

I'm working on a new calling convention for a downstream target. Our 
target normally saves and restores the return address automatically with 
the call and return instruction, so there is no need to to handle it in 
any way. The new calling convention however must save the return address 
in the caller manually. I thought that the register allocator would 
spill and restore the register holding the return address around a call, 
but I guess since we marked the register as reserved, it is not doing that.

I'm wondering now how I should correctly handle this. As a workaround I 
inserted COPY instructions to and from virtual registers around the 
call, but although that works, it looks more like a hack instead of a 
solution.
Could someone tell me how handling the save and restore of a return 
address register should look like?

Btw, I tried looking at ARM, but it looks like that LR is marked as 
callee-saved and therefore handled during prologue/epilogue creation 
(IIUC). That is not an option for us though.

Cheers,

Dominik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210719/9f6c12c9/attachment-0001.bin>


More information about the llvm-dev mailing list