Wilco Dijkstra writes: > Ping > > I noticed it would still be a good idea to add an extra barrier in the epilog > as the > scheduler doesn't appear to handle aliases of frame accesses properly. > > This patch simplifies the handling of the EH return value. We force the use > of the > frame pointer so the return location is always at FP + 8. This means we can > emit > a simple volatile access in EH_RETURN_HANDLER_RTX without needing md > patterns, splitters and frame offset calculations. The new implementation > also > fixes various bugs in aarch64_final_eh_return_addr, which does not work with > -fomit-frame-pointer, alloca or outgoing arguments.
The -fomit-frame-pointer is really broken on aarch64_find_eh_return_addr - return gen_frame_mem (DImode, - plus_constant (Pmode, - stack_pointer_rtx, - fp_offset - + cfun->machine->frame.saved_regs_size - - 2 * UNITS_PER_WORD)); the saved_regs_size includes both general and vector register saving area, while LR should be saved on top of general register area. Meanwhile saved_regs_size contains alignment amount. Given EH unwind code will invoke __builtin_unwind_init which pushes all callee-saved, both general and vector, the current function will always get wrong offset. I think the correct offset when -fomit-frame-pointer should be: "cfun->machine->frame.reg_offset[LR_REGNUM]" I have done a quick check on _Unwind_RaiseException which is the only code affected by this change. Without frame pointer, the exception handler's address is installed in different, thus wrong, stack slot. ... str x30, [sp, 112] ... str x19, [sp, 176] This approach used in this patch looks good to me. > 2016-08-10 Wilco Dijkstra <wdijk...@arm.com> > gcc/ > * config/aarch64/aarch64.md (eh_return): Remove pattern and splitter. > * config/aarch64/aarch64.h (AARCH64_EH_STACKADJ_REGNUM): Remove. > (EH_RETURN_HANDLER_RTX): New define. > * config/aarch64/aarch64.c (aarch64_frame_pointer_required): > Force frame pointer in EH return functions. > (aarch64_expand_epilogue): Add barrier for eh_return. > (aarch64_final_eh_return_addr): Remove. > (aarch64_eh_return_handler_rtx): New function. > * config/aarch64/aarch64-protos.h (aarch64_final_eh_return_addr): > Remove. > (aarch64_eh_return_handler_rtx): New prototype. -- Regards, Jiong