Hi! On Fri, Aug 11, 2017 at 12:40:11PM +0930, Alan Modra wrote: > It is possible when using out-of-line register saves or store multiple > to save some registers unnecessarily, for example one reg in the block > saved might be unused. We don't need to emit eh_frame info for those > registers as that just bloats the eh_frame info, and also can result > in an ICE when shrink-wrap gives multiple paths through the function > saving different sets of registers. All the join points need to have > identical eh_frame register save state.
It isn't just eh_frame, we might have never noticed if it was. It is also the DWARF call frame info used for debugging. > PR target/80938 > * config/rs6000/rs6000.c (rs6000_savres_strategy): Revert 2017-08-09. > Don't use store multiple if only one reg needs saving. > (rs6000_frame_related): Don't emit eh_frame for regs that > don't need saving. > (rs6000_emit_epilogue): Likewise. > + int count; > + > + for (count = 0, i = info->first_gp_reg_save; i < 32; i++) > + if (save_reg_p (i)) > + count += 1; int count = 0; for (i = info->first_gp_reg_save; i < 32; i++) if (save_reg_p (i)) count++; > @@ -25681,9 +25683,15 @@ rs6000_frame_related (rtx_insn *insn, rtx reg, > HOST_WIDE_INT val, > register save functions, or store multiple, then omit > eh_frame info for any user-defined global regs. If > eh_frame info is supplied, frame unwinding will > - restore a user reg. */ > + restore a user reg. Also omit eh_frame info for any > + reg we don't need to save, as that bloats eh_frame > + and can cause problems with shrink wrapping. Saves > + of r0 are actually saving LR, so don't omit those. */ > if (!REG_P (SET_SRC (set)) > - || !fixed_reg_p (REGNO (SET_SRC (set)))) > + || REGNO (SET_SRC (set)) == 0 > + || REGNO (SET_SRC (set)) == CR2_REGNO > + || (!fixed_reg_p (REGNO (SET_SRC (set))) > + && save_reg_p (REGNO (SET_SRC (set))))) > RTX_FRAME_RELATED_P (set) = 1; > } > RTX_FRAME_RELATED_P (insn) = 1; That "0" and "CR2_REGNO" is non-obvious, it needs a big fat comment (it's not clear that just CR2_REGNO is correct, either). Oh, and please factor out "REGNO (SET_SRC (set))". The rest looks good, but please repost. Segher