public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] aarch64: -mtrack-speculation pass capability enablement
@ 2023-02-24 17:34 Alex Coplan
0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2023-02-24 17:34 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ce2e4f958b407ae0bb9a66c34a708c74ba15eb3f
commit ce2e4f958b407ae0bb9a66c34a708c74ba15eb3f
Author: Victor Do Nascimento <victor.donascimento@arm.com>
Date: Mon Jan 16 17:09:32 2023 +0000
aarch64: -mtrack-speculation pass capability enablement
Fix the code sequence generated for speculative execution tracking so
that it uses the proper capability-handling instructions, thus
preventing the invalidation of the CSP stack pointer capability when
the speculation tracking state is encoded into the stack pointer.
For capability-enabled targets, we see the following change in the
generated tracking code from:
mov tmp, sp
and tmp, tmp, tracker
mov SP, tmp
to:
mov tmp, sp
and tmp, tmp, tracker
scvalue CSP, CSP, tmp
Diff:
---
gcc/config/aarch64/aarch64-speculation.cc | 9 ++++++---
.../gcc.target/aarch64/morello/mtrack-speculation.c | 12 ++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-speculation.cc b/gcc/config/aarch64/aarch64-speculation.cc
index f490b64ae61..2453f62c96c 100644
--- a/gcc/config/aarch64/aarch64-speculation.cc
+++ b/gcc/config/aarch64/aarch64-speculation.cc
@@ -141,14 +141,17 @@
static rtx_insn *
aarch64_speculation_clobber_sp ()
{
- rtx sp = gen_rtx_REG (DImode, SP_REGNUM);
+ rtx sp = gen_rtx_REG (Pmode, SP_REGNUM);
rtx tracker = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM);
rtx scratch = gen_rtx_REG (DImode, SPECULATION_SCRATCH_REGNUM);
start_sequence ();
- emit_insn (gen_rtx_SET (scratch, sp));
+ emit_insn (gen_rtx_SET (scratch, drop_capability (sp)));
emit_insn (gen_anddi3 (scratch, scratch, tracker));
- emit_insn (gen_rtx_SET (sp, scratch));
+ if (CAPABILITY_MODE_P (Pmode))
+ emit_insn (gen_replace_address_value_cadi (sp, sp, scratch));
+ else
+ emit_insn (gen_rtx_SET (sp, scratch));
rtx_insn *seq = get_insns ();
end_sequence ();
return seq;
diff --git a/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c b/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c
new file mode 100644
index 00000000000..ec7f3ba6a53
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+/* { dg-additional-options "-mtrack-speculation" } */
+/* Ensure the speculation tracker code does not invalidate the
+ stack pointer capability. */
+
+int
+main() {
+ int a = 10;
+ while (a)
+ a--;
+ return 0;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-24 17:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 17:34 [gcc(refs/vendors/ARM/heads/morello)] aarch64: -mtrack-speculation pass capability enablement Alex Coplan
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).