This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] -fno-merge-constants vs. string literals
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 Sep 2002 18:02:40 -0400
- Subject: [tree-ssa] -fno-merge-constants vs. string literals
Hi -
The following patch would change one way in which string literal merging
is affected by compiler flags. There are several flags (-fwritable-strings,
-fmerge-constants -O*) that interplay in interesting ways. The patch
makes all string literals be unmerged when -fno-merge-constants is
given, something now done only in another context (as an initializer,
see later in varasm.c:categorize_decl_for_section).
One side-effect of this is that a program compiled with -O0 now has
a mixture of merged and unmerged strings, whereas with the patch,
they'd all be unmerged. (-O0 implies -fno-merge-constants in
toplev.c:parse_options_and_default_flags).
The side-effect I'm interested in is related to -fmudflap, where
I'd like to force -fno-merge-constants for similar reasons. If the
first side-effect is undesirable, then I'd make the new logic further
conditional on flag_mudflap.
- FChE
2002-09-10 Frank Ch. Eigler <fche@redhat.com>
* varasm.c (categorize_decl_for_section): Obey !flag_merge_constants
for string literals, even when not an initializer.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.295.2.7
diff -u -1 -0 -p -r1.295.2.7 varasm.c
--- varasm.c 27 Aug 2002 22:11:38 -0000 1.295.2.7
+++ varasm.c 10 Sep 2002 21:29:04 -0000
@@ -4942,20 +4942,22 @@ categorize_decl_for_section (decl, reloc
int reloc;
{
enum section_category ret;
if (TREE_CODE (decl) == FUNCTION_DECL)
return SECCAT_TEXT;
else if (TREE_CODE (decl) == STRING_CST)
{
if (flag_writable_strings)
return SECCAT_DATA;
+ else if (! flag_merge_constants)
+ return SECCAT_RODATA;
else
return SECCAT_RODATA_MERGE_STR;
}
else if (TREE_CODE (decl) == VAR_DECL)
{
if (DECL_INITIAL (decl) == NULL
|| DECL_INITIAL (decl) == error_mark_node)
ret = SECCAT_BSS;
else if (! TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)