diff options
author | Eric Botcazou <ebotcazou@libertysurf.fr> | 2004-01-30 15:16:43 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2004-01-30 14:16:43 +0000 |
commit | 5e9295fa05762dd503c5310b0b28e3f352f876ae (patch) | |
tree | 2f8ffaed307795a09c0dc5b8efae1560a53c708c /gcc/varasm.c | |
parent | 7dcc98e25c7da0f7eeef93d77d0ead2e5814b019 (diff) | |
download | gcc-5e9295fa05762dd503c5310b0b28e3f352f876ae.zip gcc-5e9295fa05762dd503c5310b0b28e3f352f876ae.tar.gz gcc-5e9295fa05762dd503c5310b0b28e3f352f876ae.tar.bz2 |
re PR c/12818 (-fwritable strings triggers bad code generation)
PR c/12818
* varasm.c (const_hash_1) <STRING_CST>: Use the
address to compute the hash value if flag_writable_strings.
(compare_constant) <STRING_CST>: Compare the addresses
if flag_writable_strings.
(build_constant_desc): Do not copy the expression for a
STRING_CST if flag_writable_strings.
From-SVN: r76958
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index e44d288..7af71bf 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2057,7 +2057,7 @@ struct rtx_const GTY(()) /* Uniquize all constants that appear in memory. Each constant in memory thus far output is recorded - in `const_hash_table'. */ + in `const_desc_table'. */ struct constant_descriptor_tree GTY(()) { @@ -2104,9 +2104,18 @@ const_hash_1 (const tree exp) return real_hash (TREE_REAL_CST_PTR (exp)); case STRING_CST: - p = TREE_STRING_POINTER (exp); - len = TREE_STRING_LENGTH (exp); + if (flag_writable_strings) + { + p = (char *) &exp; + len = sizeof exp; + } + else + { + p = TREE_STRING_POINTER (exp); + len = TREE_STRING_LENGTH (exp); + } break; + case COMPLEX_CST: return (const_hash_1 (TREE_REALPART (exp)) * 5 + const_hash_1 (TREE_IMAGPART (exp))); @@ -2221,7 +2230,7 @@ compare_constant (const tree t1, const tree t2) case STRING_CST: if (flag_writable_strings) - return 0; + return t1 == t2; if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))) return 0; @@ -2425,7 +2434,10 @@ build_constant_desc (tree exp) struct constant_descriptor_tree *desc; desc = ggc_alloc (sizeof (*desc)); - desc->value = copy_constant (exp); + if (flag_writable_strings && TREE_CODE (exp) == STRING_CST) + desc->value = exp; + else + desc->value = copy_constant (exp); /* Create a string containing the label name, in LABEL. */ labelno = const_labelno++; @@ -2466,7 +2478,7 @@ build_constant_desc (tree exp) If DEFER is nonzero, this constant can be deferred and output only if referenced in the function after all optimizations. - The const_hash_table records which constants already have label strings. */ + `const_desc_table' records which constants already have label strings. */ rtx output_constant_def (tree exp, int defer) |