[PATCH] D144541: [X86] Save/restore base pointer register when it is clobbered

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 25 20:19:40 PST 2023


efriedma added a comment.

In D144541#4152873 <https://reviews.llvm.org/D144541#4152873>, @LuoYuanke wrote:

> In D144541#4152619 <https://reviews.llvm.org/D144541#4152619>, @efriedma wrote:
>
>> What happens if an inline asm both has a memory reference, and clobbers the base pointer?  How do we refer to memory?
>
> That's a good question. Maybe exchange ebp and esi. Base pointer (esi) is used to reference the stack slot before realignment and frame pointer (ebp) is used to reference stack slot after realignment. Since ebp is reserved in ABI, user can not clobber ebp in inline assembly. What do you think?

Possible alternatives:

- Use ebp... but this messes with unwinding, and doesn't actually solve the issue in general (if the inline asm references function arguments, those references are ebp-relative).
- Use some other register not used by the inline asm as a temporary base pointer.
- We use a different prologue that avoids the need for a base pointer.  See discussion at https://github.com/llvm/llvm-project/issues/17204


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144541



More information about the llvm-commits mailing list