public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Don't put compile-time CADI constants in .data.rel.ro Date: Fri, 6 May 2022 14:45:36 +0000 (GMT) [thread overview] Message-ID: <20220506144536.AE98E3836030@sourceware.org> (raw) https://gcc.gnu.org/g:538b00262bd311dfed679093ef1411002ababa72 commit 538b00262bd311dfed679093ef1411002ababa72 Author: Richard Sandiford <richard.sandiford@arm.com> Date: Tue May 3 10:46:58 2022 +0100 Don't put compile-time CADI constants in .data.rel.ro We were putting compile-time CADI constants in .data.rel.ro even though they don't need relocation. This isn't wrong in a dynamic object, just perhaps a little redundant. However, the linux kernel (rightly) doesn't expect to have to deal with runtime relocations, so its linker script checks that .data.rel.ro is empty. The patch moves the RELOC_CAPABILITY handling from compute_reloc_for_rtx to compute_reloc_for_rtx_1 and makes it conditional on seeing an (inner) LABEL_REF or SYMBOL_REF. CONST_NULL-based constants are explicitly not included. This means that we can go back to the trunk version of compute_reloc_for_rtx. That version isn't inherently better than the branch-local one, but I thought it might reduce surprises when doing a rebase onto a later release. Diff: --- gcc/config/aarch64/aarch64.c | 4 +++- gcc/output.h | 2 ++ .../gcc.target/aarch64/morello/const-pool-2.c | 3 +++ gcc/varasm.c | 26 +++++++++++----------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 2ddfb819899..0879583288f 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -9733,7 +9733,9 @@ aarch64_can_use_per_function_literal_pools_p (const_rtx x) { /* Real capabilities aren't link-time constants, so putting one in the text section would require the text segment to be load-time writable. */ - if (!TARGET_CAPABILITY_FAKE && x && CAPABILITY_MODE_P (GET_MODE (x))) + if (!TARGET_CAPABILITY_FAKE + && x + && (compute_reloc_for_rtx (x) & RELOC_CAPABILITY)) return false; return (aarch64_pcrelative_literal_loads diff --git a/gcc/output.h b/gcc/output.h index f7335da8f17..7fe50f3163a 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -365,6 +365,8 @@ extern bool decl_readonly_section (const_tree, int); given a constant expression. */ extern int compute_reloc_for_constant (tree); +extern int compute_reloc_for_rtx (const_rtx); + /* User label prefix in effect for this compilation. */ extern const char *user_label_prefix; diff --git a/gcc/testsuite/gcc.target/aarch64/morello/const-pool-2.c b/gcc/testsuite/gcc.target/aarch64/morello/const-pool-2.c new file mode 100644 index 00000000000..987fda71c99 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/morello/const-pool-2.c @@ -0,0 +1,3 @@ +__intcap_t foo() { return 0x12345678abcdefLL; } + +/* { dg-final { scan-assembler-not {\.data\.rel} } } */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 6dbb478e93e..4ec8ca79205 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -7170,12 +7170,19 @@ default_unique_section (tree decl, int reloc) static int compute_reloc_for_rtx_1 (const_rtx x) { + int reloc = 0; switch (GET_CODE (x)) { case SYMBOL_REF: - return SYMBOL_REF_LOCAL_P (x) ? 1 : 2; case LABEL_REF: - return 1; + if (CAPABILITY_MODE_P (GET_MODE (x))) + reloc |= RELOC_CAPABILITY; + if (SYMBOL_REF_P (x) && !SYMBOL_REF_LOCAL_P (x)) + reloc |= 2; + else + reloc |= 1; + return reloc; + default: return 0; } @@ -7185,34 +7192,27 @@ compute_reloc_for_rtx_1 (const_rtx x) is a mask for which bit 1 indicates a global relocation, and bit 0 indicates a local relocation. */ -static int +int compute_reloc_for_rtx (const_rtx x) { - int reloc = 0; - switch (GET_CODE (x)) { case SYMBOL_REF: case LABEL_REF: - reloc = compute_reloc_for_rtx_1 (x); - break; + return compute_reloc_for_rtx_1 (x); case CONST: { + int reloc = 0; subrtx_iterator::array_type array; FOR_EACH_SUBRTX (iter, array, x, ALL) reloc |= compute_reloc_for_rtx_1 (*iter); + return reloc; } - break; default: return 0; } - - if (CAPABILITY_MODE_P (GET_MODE (x))) - reloc |= RELOC_CAPABILITY; - - return reloc; } section *
reply other threads:[~2022-05-06 14:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220506144536.AE98E3836030@sourceware.org \ --to=matmal01@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).