On Mon, Jun 30, 2025 at 10:41 AM Hongtao Liu <[email protected]> wrote:
>
> On Mon, Jun 30, 2025 at 10:37 AM Hongtao Liu <[email protected]> wrote:
> >
> > On Sat, Jun 28, 2025 at 8:30 PM H.J. Lu <[email protected]> wrote:
> > >
> > > Update functions with no_callee_saved_registers/preserve_none attribute
> > > to preserve frame pointer since caller may use it to save the current
> > > stack:
> > >
> > > pushq %rbp
> > > movq %rsp, %rbp
> > > ...
> > > call function
> > > ...
> > > leave
> > > ret
> > >
> > > If callee changes frame pointer without restoring it, caller will fail
> > > to restore its stack after callee returns.
> > Do we know why the caller failed to restore rbp? Are there any
> > assumptions in the middle-end that frame pointers must be callee saved
> > registers(even if it's marked as caller-saved)?
> >
> > >
> >
> > /* The current function is a function specified with the
> > "no_callee_saved_registers" attribute. */
> > TYPE_NO_CALLEE_SAVED_REGISTERS,
> > - /* The current function is a function specified with the "noreturn"
> > - attribute. */
> > - TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP,
> >
> > Comments of "noreturn" part should be merged into that of
> > TYPE_NO_CALLEE_SAVED_REGISTERS.
> >
> > +callee-saved registers. That is, all registers, except for stack and
> > +frame pointers, can be used as scratch registers. For example, this
> >
> > The patch only excludes frame pointers but the document mentions both
> > stack and frame pointers?
>
> And documents of preserve_none attribute should be changed since your
> patch also exclude frame_pointer for TYPE_PRESERVE_NONE.
Since preserve_none is documented as
This attribute is similar to @code{no_callee_saved_registers}, except
on x86-64, r12, r13, r14, r15, rdi and rsi registers are used for
integer parameter passing and this calling convention is subject to
change.
no_callee_saved_registers covers preserve_none on frame pointer.
> case TYPE_NO_CALLEE_SAVED_REGISTERS:
> case TYPE_PRESERVE_NONE:
> - return false;
> -
> - case TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP:
> if (regno != HARD_FRAME_POINTER_REGNUM)
> return false;
>
> >
> >
> >
> > --
> > BR,
> > Hongtao
>
>
>
> --
> BR,
> Hongtao
--
H.J.