James Greenhalgh wrote: > +/* Determine whether a frame chain needs to be generated. */ > +static bool > +aarch64_needs_frame_chain (void) > +{ > + /* Force a frame chain for EH returns so the return address is at FP+8. */ > + if (frame_pointer_needed || crtl->calls_eh_return) > + return true;
> To match the original logic, I think this needs to not return true, but set > some temporary to true which may be overwritten by... It's only overwritten if false, once true it cannot ever become false. > + > + /* A leaf function cannot have calls or write LR. */ > + bool is_leaf = crtl->is_leaf && !df_regs_ever_live_p (LR_REGNUM); > + > + /* Don't use a frame chain in leaf functions if leaf frame pointers > + are disabled. */ > + if (flag_omit_leaf_frame_pointer && is_leaf) > + return false; > This. No, a leaf function with alloca or EH return still must use a frame pointer. > + > + return aarch64_use_frame_pointer; > +} > + > I say that because here > - /* Force a frame chain for EH returns so the return address is at FP+8. */ > - cfun->machine->frame.emit_frame_chain > - = frame_pointer_needed || crtl->calls_eh_return; > - > We fall through to the next check. > - /* Emit a frame chain if the frame pointer is enabled. > - If -momit-leaf-frame-pointer is used, do not use a frame chain > - in leaf functions which do not use LR. */ > - if (flag_omit_frame_pointer == 2 > - && !(flag_omit_leaf_frame_pointer && crtl->is_leaf > - && !df_regs_ever_live_p (LR_REGNUM))) > - cfun->machine->frame.emit_frame_chain = true; > + cfun->machine->frame.emit_frame_chain = aarch64_needs_frame_chain (); > That may well have been a long-standing bug, but I wanted to query it > as you don't mention any bug fixes in the patch cover letter. There is no bug here, the code is non-trivial but it does exactly what it says - forcing the frame chain on when required in a non-leaf or a leaf if leaf frame pointer omission is disabled. The point of the new code is to make it a bit simpler to read. Wilco