From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [PATCH] aarch64: Fix eh_return for -mtrack-speculation [PR112987]
Date: Wed, 17 Jan 2024 14:37:03 +0000 [thread overview]
Message-ID: <20240117143703.2998316-1-szabolcs.nagy@arm.com> (raw)
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);
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));
--
2.25.1
next reply other threads:[~2024-01-17 14:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 14:37 Szabolcs Nagy [this message]
2024-01-24 17:41 ` Richard Sandiford
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=20240117143703.2998316-1-szabolcs.nagy@arm.com \
--to=szabolcs.nagy@arm.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).