[PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)
Joerg Sonnenberger via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 7 13:08:53 PDT 2016
On Sun, Aug 07, 2016 at 11:08:22AM +0000, Amjad Aboud via cfe-commits wrote:
> aaboud marked 3 inline comments as done.
> aaboud added a comment.
> In https://reviews.llvm.org/D22045#506996, @joerg wrote:
> > For what it is worth, this certainly seems to be misnamed. By nature, if it doesn't preserve at least the stack pointer, there is no way to recover on return, right?
> I am not sure I understand what you mean!
> When you said "if it does not preserve the stack pointer", did you mean the "caller"?
> Maybe it need more clarification on that, but stack pointer should be
> saved by the caller (via the call instruction), but even in this case
> the callee must preserve the stack pointer, right? otherwise the return
> will not work. So, from callee point of view it still cannot assume
> that any register is a scratch register and it need to preserve it
> before modifying.
The call instruction itself only saves the return address. But the point
is that the stack pointer must be the same after the function call as
before. As such, the stack pointer is always implicitly caller saved and
must not be clobbered.
More information about the cfe-commits