From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v5 2/2] IBM zSystems: Define CODE_LABEL_BOUNDARY
Date: Tue, 27 Sep 2022 02:23:34 +0200 [thread overview]
Message-ID: <20220927002334.651057-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20220927002334.651057-1-iii@linux.ibm.com>
Currently s390 emits the following sequence to store a frame_pc:
a:
.LASANPC0:
lg %r1,.L5-.L4(%r13)
la %r1,0(%r1,%r12)
stg %r1,176(%r11)
.L5:
.quad .LASANPC0@GOTOFF
The reason GOT indirection is used instead of larl is that gcc does not
know that .LASANPC0, being a code label, is aligned on a 2-byte
boundary, and larl can load only even addresses.
Define CODE_LABEL_BOUNDARY in order to get rid of GOT indirection:
larl %r1,.LASANPC0
stg %r1,176(%r11)
gcc/ChangeLog:
2020-06-30 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/s390.h (CODE_LABEL_BOUNDARY): Specify that s390
requires code labels to be aligned on a 2-byte boundary.
gcc/testsuite/ChangeLog:
2019-06-30 Ilya Leoshkevich <iii@linux.ibm.com>
* gcc.target/s390/asan-no-gotoff.c: New test.
---
gcc/config/s390/s390.h | 3 +++
gcc/testsuite/gcc.target/s390/asan-no-gotoff.c | 15 +++++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/s390/asan-no-gotoff.c
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index be566215df2..7d078ce6868 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -368,6 +368,9 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
/* Allocation boundary (in *bits*) for the code of a function. */
#define FUNCTION_BOUNDARY 64
+/* Alignment required for a code label, in bits. */
+#define CODE_LABEL_BOUNDARY 16
+
/* There is no point aligning anything to a rounder boundary than this. */
#define BIGGEST_ALIGNMENT 64
diff --git a/gcc/testsuite/gcc.target/s390/asan-no-gotoff.c b/gcc/testsuite/gcc.target/s390/asan-no-gotoff.c
new file mode 100644
index 00000000000..f555e4e96f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/asan-no-gotoff.c
@@ -0,0 +1,15 @@
+/* Test that ASAN labels are referenced without unnecessary indirections. */
+
+/* { dg-do compile } */
+/* { dg-options "-fPIE -O2 -fsanitize=kernel-address --param asan-stack=1" } */
+
+extern void c (int *);
+
+void a ()
+{
+ int b;
+ c (&b);
+}
+
+/* { dg-final { scan-assembler {\tlarl\t%r\d+,\.LASANPC\d+} } } */
+/* { dg-final { scan-assembler-not {\.LASANPC\d+@GOTOFF} } } */
--
2.37.2
next prev parent reply other threads:[~2022-09-27 0:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 0:23 [PATCH v5 0/2] IBM zSystems: Improve storing asan frame_pc Ilya Leoshkevich
2022-09-27 0:23 ` [PATCH v5 1/2] asan: specify alignment for LASANPC labels Ilya Leoshkevich
2022-09-27 0:23 ` Ilya Leoshkevich [this message]
2022-10-18 2:28 ` PING [PATCH v5 0/2] IBM zSystems: Improve storing asan frame_pc Ilya Leoshkevich
2022-10-25 17:37 ` Jakub Jelinek
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=20220927002334.651057-3-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.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).