+2015-05-07 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.
+
2015-05-07 Jeff Law <law@redhat.com>
* match.pd (bit_and (plus/minus (convert @0) (convert @1) mask): New
+2015-05-07 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR middle-end/192
+ PR middle-end/54303
+ * gcc.dg/fdata-sections-2.c: New file.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR testsuite/66046
--- /dev/null
+/* PR middle-end/192 */
+/* PR middle-end/54303 */
+
+/* This checks that string constants are put in per-function rodata
+ sections, so that they can be garbage collected. */
+
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O -ffunction-sections -fdata-sections" } */
+
+const char *f1(void) { return "falderalde"; }
+const char *f2(void) { return "a"; }
+const char *f3(void) { return "falderalde"; }
+const char *f4(void) { return "eralde"; }
+
+/* { dg-final { scan-assembler {\.rodata\.f1\.str} } } */
+/* { dg-final { scan-assembler {\.rodata\.f2\.str} } } */
+/* { dg-final { scan-assembler-not {\.rodata\.f3\.str} } } */
+/* { dg-final { scan-assembler {\.rodata\.f4\.str} } } */
return readonly_data_section;
}
+/* A subroutine of mergeable_string_section and mergeable_constant_section. */
+
+static 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 *
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)));
&& 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));