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

YangKeao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 08:45:59 PDT 2021


YangKeao added a comment.

> What registers can be used? I did a quick search and couldn't find anything.

I found the available dwarf registers under the x86 register table in LLVM (X86RegisterInfo.td).

> 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, RDX, RCX, RSI, R8-R11` could be a good choice, and for 32 bit, it could only be choosen from `EAX, EDX, ECX, ESI`

> This makes me wonder, though: why not leave selection of the register to use here to regalloc?

Sounds like a good idea. But I'm not familiar with LLVM codes. Is there any example on how to use the regalloc?



================
Comment at: llvm/test/CodeGen/X86/stack-clash-large.ll:22
+; CHECK-X86-64-NEXT:	.cfi_def_cfa_register %rdi
+; CHECK-X86-64-NEXT:	.cfi_adjust_cfa_offset 69632
 ; CHECK-X86-64-NEXT:   .LBB0_1:
----------------
nagisa wrote:
> I… think this wants to be a `def_cfa_offset`? `def_cfa_register` does not reset the offset so its not at all obvious what this is offsetting from.
> 
> Alternatively there's a form that combines both setting the new register and the offset into a single directive:
> 
> ```
> lang=asm
> .cfi_def_cfa %rdi, 69632
> ```
The problem is that I don't know the accurate offset. When the callee-saved registers are pushed to the stack, there will be an offset before probing the stack (if I understand the prolog part correctly, please tell me if I'm wrong).


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