From: Richard Sandiford <richard.sandiford@arm.com>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] aarch64: Fix eh_return for -mtrack-speculation [PR112987]
Date: Wed, 24 Jan 2024 17:41:00 +0000 [thread overview]
Message-ID: <mpt8r4ehbo3.fsf@arm.com> (raw)
In-Reply-To: <20240117143703.2998316-1-szabolcs.nagy@arm.com> (Szabolcs Nagy's message of "Wed, 17 Jan 2024 14:37:03 +0000")
Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> Recent commit introduced a conditional branch in eh_return epilogues
> that is not compatible with speculation tracking:
>
> commit 426fddcbdad6746fe70e031f707fb07f55dfb405
> Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
> CommitDate: 2023-11-27 15:52:48 +0000
>
> aarch64: Use br instead of ret for eh_return
>
> gcc/ChangeLog:
>
> PR target/112987
> * config/aarch64/aarch64.cc (aarch64_expand_epilogue): Use
> explicit compare and separate jump with speculation tracking.
> ---
> gcc/config/aarch64/aarch64.cc | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index e6bd3fd0bb4..e6de62dc02a 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -9879,7 +9879,17 @@ aarch64_expand_epilogue (rtx_call_insn *sibcall)
> is just as correct as retaining the CFA from the body
> of the function. Therefore, do nothing special. */
> rtx label = gen_label_rtx ();
> - rtx x = gen_rtx_EQ (VOIDmode, EH_RETURN_TAKEN_RTX, const0_rtx);
> + rtx x;
> + if (aarch64_track_speculation)
> + {
> + /* Emit an explicit compare, so cc can be tracked. */
> + rtx cc_reg = aarch64_gen_compare_reg (EQ,
> + EH_RETURN_TAKEN_RTX,
> + const0_rtx);
> + x = gen_rtx_EQ (GET_MODE (cc_reg), cc_reg, const0_rtx);
> + }
> + else
> + x = gen_rtx_EQ (VOIDmode, EH_RETURN_TAKEN_RTX, const0_rtx);
It looks from a quick scan like we already have 3 instances of
this kind of construct. Would you mind factoring them out into
a helper?
E.g. (strawman):
static rtx
aarch64_gen_compare_zero_and_branch (rtx_code code, rtx x, rtx_label *label)
{
}
that returns the SET pattern. The caller can then emit the pattern
using whichever interface is appropriate.
Thanks,
Richard
> x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
> gen_rtx_LABEL_REF (Pmode, label), pc_rtx);
> rtx jump = emit_jump_insn (gen_rtx_SET (pc_rtx, x));
prev parent reply other threads:[~2024-01-24 17:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 14:37 Szabolcs Nagy
2024-01-24 17:41 ` Richard Sandiford [this message]
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=mpt8r4ehbo3.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=szabolcs.nagy@arm.com \
/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).