On Mon, Jun 30, 2025 at 11:16 AM H.J. Lu <[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)? > > Since RBP is changed by callee, "leave", which does > > mov %rbp, %rsp > pop %rbp > > no longer works as RBP is wrong. Reading the testcase, it looks like the issue is related to the mixusaged of omit-frame-pointer in the callee but no-omit-frame-pointer in the caller side relies on the fact that rbp must be a callee-saved register?
Since ira will take HARD_FRAME_POINTER_REGNUM as a fixed register in the caller(when no-omit-frame-pointer) but callee takes it as a scratch register (since omit-frame-pointer && no_callee_saved_register attribute) > > > > > > > > /* 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. > > Will update. > > > +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? > > Stack pointer is implied. My patch makes it clear. It's a fixed register, I c. > > > > > > > -- > > BR, > > Hongtao > > > > -- > H.J. -- BR, Hongtao
