From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH] Make mergeable read-only sections per-function, if requested.
Date: Wed, 06 May 2015 23:00:00 -0000 [thread overview]
Message-ID: <8f67f9aad3d5b98cb428dea0316a86615b89adb9.1430937961.git.segher@kernel.crashing.org> (raw)
Currently GCC does not put mergeable read-only data in a per-function
section, so the -gc-sections linker option does not do much for such
data. Fix that.
Bootstrapped and tested on powerpc64-linux; no regressions.
Is this okay for trunk?
Segher
2015-05-06 Segher Boessenkool <segher@kernel.crashing.org>
PR middle-end/192
PR middle-end/54303
* varasm.c (function_mergeable_rodata_prefix): New function.
(mergeable_string_section): Use it.
(mergeable_constant_section): Use it.
---
gcc/varasm.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 62d5163..d8f077d 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -783,6 +783,16 @@ default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED)
return readonly_data_section;
}
+const char *
+function_mergeable_rodata_prefix (void)
+{
+ section *s = targetm.asm_out.function_rodata_section (current_function_decl);
+ if (SECTION_STYLE (s) == SECTION_NAMED)
+ return s->named.name;
+ else
+ return targetm.asm_out.mergeable_rodata_prefix;
+}
+
/* Return the section to use for string merging. */
static section *
@@ -804,7 +814,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
const char *str;
HOST_WIDE_INT i;
int j, unit;
- const char *prefix = targetm.asm_out.mergeable_rodata_prefix;
+ const char *prefix = function_mergeable_rodata_prefix ();
char *name = (char *) alloca (strlen (prefix) + 30);
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
@@ -857,7 +867,7 @@ mergeable_constant_section (machine_mode mode ATTRIBUTE_UNUSED,
&& align <= 256
&& (align & (align - 1)) == 0)
{
- const char *prefix = targetm.asm_out.mergeable_rodata_prefix;
+ const char *prefix = function_mergeable_rodata_prefix ();
char *name = (char *) alloca (strlen (prefix) + 30);
sprintf (name, "%s.cst%d", prefix, (int) (align / 8));
--
1.8.1.4
next reply other threads:[~2015-05-06 23:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 23:00 Segher Boessenkool [this message]
2015-05-07 8:15 ` Marek Polacek
2015-05-07 12:31 ` Segher Boessenkool
2015-05-07 13:31 ` Jeff Law
2015-05-07 15:51 ` Segher Boessenkool
2015-05-07 13:29 ` Jeff Law
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=8f67f9aad3d5b98cb428dea0316a86615b89adb9.1430937961.git.segher@kernel.crashing.org \
--to=segher@kernel.crashing.org \
--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).