From: Segher Boessenkool <segher@kernel.crashing.org>
To: Alan Modra <amodra@gmail.com>
Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com
Subject: Re: [RS6000] PR 80938, Don't emit eh_frame for regs that don't need saving
Date: Tue, 15 Aug 2017 10:40:00 -0000 [thread overview]
Message-ID: <20170815072823.GS13471@gate.crashing.org> (raw)
In-Reply-To: <20170811031011.GO16312@bubble.grove.modra.org>
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
next prev parent reply other threads:[~2017-08-15 7:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 21:16 [PATCH] rs6000: Use SAVE_MULTIPLE only if we restore what it saves (PR80938) Segher Boessenkool
2017-08-10 4:18 ` Alan Modra
2017-08-10 4:44 ` Segher Boessenkool
2017-08-10 5:26 ` Alan Modra
2017-08-10 13:46 ` Segher Boessenkool
2017-08-11 4:58 ` [RS6000] PR 80938, Don't emit eh_frame for regs that don't need saving Alan Modra
2017-08-15 10:40 ` Segher Boessenkool [this message]
2017-08-16 0:13 ` Alan Modra
2017-08-17 2:23 ` Segher Boessenkool
2017-08-17 5:28 ` Alan Modra
2017-08-17 5:50 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170815072823.GS13471@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=amodra@gmail.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).