[PATCH] D141020: [X86][ABI] Clobber %RAX for preserve_allcc and preserve_mostcc CCs

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 17:58:34 PST 2023


pengfei added a comment.

In D141020#4038220 <https://reviews.llvm.org/D141020#4038220>, @efriedma wrote:

> Having a register be both preserved and used to store a return value is obviously a contradiction.  However, it's consistent to say that a register is preserved if and only if it is not used to return a value.  (Not sure off the top of my head what changes are required to make that work correctly.)
>
> The C calling convention uses RAX/RDX/XMM0/XMM1 to return values, and LLVM additionally allows using RCX/XMM2/XMM3 for certain IR signatures.  So I don't think just removing RAX from the list does the right thing.

Agreed! FPRs is not a problem as the doc says they are not preserved. But we do use RDX sometime, e.g.: https://godbolt.org/z/sWKKbjMvz
So yes, we may need a method to override the preserve list when RAX/RDX are used as return registers. Not sure if the current framework support or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141020



More information about the llvm-commits mailing list