[PATCH] D98789: [PEI] add dwarf information for stack probe

Simonas Kazlauskas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 09:40:30 PDT 2021


nagisa added a comment.

In D98789#2634751 <https://reviews.llvm.org/D98789#2634751>, @YangKeao wrote:

>> Any register that isn't callee-preserved could be used (or any register in general if its spilled first), assuming it isn't used for something else already. I did a quick search in an effort to figure out which registers are callee-saved on x86, but couldn't find anything definitive :(
>
> It seems that different platform will have different set of callee-preserved register. I also found them in the list in LLVM (which is refered in the function `getCalleeSavedRegs` of `llvm/lib/Target/X86/X86RegisterInfo.cpp`). Sadly, it seems like `RDI` is more likely to be a callee-saved register.
>
> Only considering the `SYSV` and `Windows`, all callee-saved registers are:
>
>   X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP
>   X86::RBX, X86::RBP, X86::RDI, X86::RSI, X86::R12, X86::R13, X86::R14, X86::R15, X86::XMM6, X86::XMM7, X86::XMM8, X86::XMM9, X86::XMM10, X86::XMM11, X86::XMM12, X86::XMM13, X86::XMM14, X86::XMM15
>
> And all available dwarf registers are:
>
>   32bit:
>   EAX, EDX, ECX, EBX, ESI, EDI, EBP, ESP, EIP
>   64bit, X86-64:
>   RAX, RDX, RCX, RBX, RSI, RDI, RBP, RSP, R8-R15, RIP
>
> For 64bit, `RAX, RCX, RDX, R8-R11` could be a good choice, and for 32 bit, it could only be choosen from `EAX, ECX, EDX`

A care must be taken to not overwrite the arguments as well. For instance on SysV x86_64 ABI `rdi`, `rsi`, `rdx`, `rcx`, `r8`, `r9` are used to pass in integer arguments. For functions with a small number of arguments one of these could be reused, but if a function happens to use all of them, unconditional use of `rdx` would clobber the argument.

In D98789#2634751 <https://reviews.llvm.org/D98789#2634751>, @YangKeao wrote:

> Sounds like a good idea. But I'm not familiar with LLVM codes. Is there any example on how to use the regalloc?
>
> (I don't know whether it will make this patch too complicate. Allocating stack probe register with regalloc and fixing the dwarf sound like two things and I'd like to do it in a separated patch.)

You would probably have to split the patches up into distinct parts, yes (first one adjusting the backend to allocate virtual registers and the next being this one).

I'll get back to you with advice on how to specify a virtual register a little bit later –


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98789/new/

https://reviews.llvm.org/D98789



More information about the llvm-commits mailing list