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.
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