Dear there,
I was wondering how to preserve registers (caller saved) across calls. I implemented getCalleeSavedRegs and getCallPreservedMask. But the non-callee-saved registers are still not saved by caller. I want to spill these registers in use on stack right before the call. From my understanding, the register allocator in llvm will do the spill and restoring automatically? Is there anything I was supposed to do to make it happen?
Thanks,
Xiaochu
Is the preserved mask passed down to your Call instruction in LowerCall ?
Marcello
Hi Marcello,
Thanks for your reply. I will try to pass down the mask!
I have one more question. In my backend I return CSR_RegMask in getCallPreservedMask and return CSR_SaveList in getCalleeSavedRegs. Is that a correct setup? I dumped the regmask and found that callee saved regs are marked 1 and non-callee saved regs are 0.
Thanks,
Xiaochu
Yes, RegMask is what you should use for the CallPreservedMask.
It means that the registers set as 1 are preserved from the Call (the callee saved) and the ones marked as 0 need to be saved instead.
Cheers,
Marcello
Thank you so much, Marcello!
Regards,
Xiaochu