varasm.c (mergeable_string_section): Check for embedded NULs and NUL termination in the first int_size_in_bytes...
* varasm.c (mergeable_string_section): Check for embedded NULs and NUL termination in the first int_size_in_bytes (TREE_TYPE (decl)) rather than TREE_STRING_LENGTH bytes. * gcc.dg/merge-all-constants-1.c: New test. From-SVN: r114842
This commit is contained in:
parent
470f18fcaa
commit
0841534abd
@ -1,3 +1,9 @@
|
||||
2006-06-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* varasm.c (mergeable_string_section): Check for embedded NULs and
|
||||
NUL termination in the first int_size_in_bytes (TREE_TYPE (decl))
|
||||
rather than TREE_STRING_LENGTH bytes.
|
||||
|
||||
2006-06-21 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
* ggc-page.c (extra_order_size_table): Add var_ann_d,
|
||||
|
@ -1,3 +1,7 @@
|
||||
2006-06-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* gcc.dg/merge-all-constants-1.c: New test.
|
||||
|
||||
2006-06-20 Janis Johnson <janis187@us.ibm.com>
|
||||
|
||||
PR c++/28113
|
||||
|
8
gcc/testsuite/gcc.dg/merge-all-constants-1.c
Normal file
8
gcc/testsuite/gcc.dg/merge-all-constants-1.c
Normal file
@ -0,0 +1,8 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-w -O2 -fmerge-all-constants" } */
|
||||
|
||||
const char str1[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char str2[38] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
/* { dg-final { scan-assembler-not "\.rodata\.str" } } */
|
@ -655,16 +655,20 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
|
||||
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
|
||||
unsigned int flags ATTRIBUTE_UNUSED)
|
||||
{
|
||||
HOST_WIDE_INT len;
|
||||
|
||||
if (HAVE_GAS_SHF_MERGE && flag_merge_constants
|
||||
&& TREE_CODE (decl) == STRING_CST
|
||||
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
|
||||
&& align <= 256
|
||||
&& TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
|
||||
&& (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
|
||||
&& TREE_STRING_LENGTH (decl) >= len)
|
||||
{
|
||||
enum machine_mode mode;
|
||||
unsigned int modesize;
|
||||
const char *str;
|
||||
int i, j, len, unit;
|
||||
HOST_WIDE_INT i;
|
||||
int j, unit;
|
||||
char name[30];
|
||||
|
||||
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
|
||||
@ -676,7 +680,6 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
|
||||
align = modesize;
|
||||
|
||||
str = TREE_STRING_POINTER (decl);
|
||||
len = TREE_STRING_LENGTH (decl);
|
||||
unit = GET_MODE_SIZE (mode);
|
||||
|
||||
/* Check for embedded NUL characters. */
|
||||
|
Loading…
Reference in New Issue
Block a user