diff options
author | Geoffrey Keating <geoffk@apple.com> | 2004-09-18 05:50:52 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2004-09-18 05:50:52 +0000 |
commit | a396f8ae242ddd9993230025093b5f768647d194 (patch) | |
tree | 5b612839071d1427646211852251d0557c61a619 /gcc/tree.c | |
parent | 9aa44508a821e8de072de1f6d8ea344753a0a4d1 (diff) | |
download | gcc-a396f8ae242ddd9993230025093b5f768647d194.zip gcc-a396f8ae242ddd9993230025093b5f768647d194.tar.gz gcc-a396f8ae242ddd9993230025093b5f768647d194.tar.bz2 |
re PR pch/13361 (const wchar_t * strings not stored in pch)
* tree-inline.c (copy_tree_r): Don't duplicate constants, they're
shared anyway.
PR pch/13361
* c-typeck.c (constructor_asmspec): Delete.
(struct initializer_stack): Delete field 'asmspec'.
(start_init): Delete saving of asmspec.
(finish_init): Don't update constructor_asmspec.
* dwarf2out.c (rtl_for_decl_location): Duplicate string from tree.
* stmt.c (expand_asm): Duplicate strings from tree.
(expand_asm_operands): Likewise.
* tree.c (tree_size): Update computation of size of STRING_CST.
(make_node): Don't make STRING_CST nodes.
(build_string): Allocate string with tree node.
(tree_code_size): Clean up assertions, don't allow requests
for "the size of a STRING_CST".
* tree.def (STRING_CST): Update comment.
* tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST.
(tree_string): Place contents of string in tree node.
* config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string
from tree.
From-SVN: r87695
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -159,17 +159,12 @@ decl_assembler_name (tree decl) return DECL_CHECK (decl)->decl.assembler_name; } -/* Compute the number of bytes occupied by a tree with code CODE. This - function cannot be used for TREE_VEC or PHI_NODE codes, which are of - variable length. */ +/* Compute the number of bytes occupied by a tree with code CODE. + This function cannot be used for TREE_VEC, PHI_NODE, or STRING_CST + codes, which are of variable length. */ size_t tree_code_size (enum tree_code code) { - /* We can't state the size of a TREE_VEC or PHI_NODE - without knowing how many elements it will have. */ - gcc_assert (code != TREE_VEC); - gcc_assert (code != PHI_NODE); - switch (TREE_CODE_CLASS (code)) { case tcc_declaration: /* A decl node */ @@ -194,7 +189,7 @@ tree_code_size (enum tree_code code) case REAL_CST: return sizeof (struct tree_real_cst); case COMPLEX_CST: return sizeof (struct tree_complex); case VECTOR_CST: return sizeof (struct tree_vector); - case STRING_CST: return sizeof (struct tree_string); + case STRING_CST: gcc_unreachable (); default: return lang_hooks.tree_size (code); } @@ -208,7 +203,8 @@ tree_code_size (enum tree_code code) case ERROR_MARK: case PLACEHOLDER_EXPR: return sizeof (struct tree_common); - case PHI_NODE: + case TREE_VEC: + case PHI_NODE: gcc_unreachable (); case SSA_NAME: return sizeof (struct tree_ssa_name); @@ -241,6 +237,9 @@ tree_size (tree node) return (sizeof (struct tree_vec) + (TREE_VEC_LENGTH (node) - 1) * sizeof(char *)); + case STRING_CST: + return sizeof (struct tree_string) + TREE_STRING_LENGTH (node) - 1; + default: return tree_code_size (code); } @@ -719,10 +718,23 @@ build_real_from_int_cst (tree type, tree i) tree build_string (int len, const char *str) { - tree s = make_node (STRING_CST); + tree s; + size_t length; + + length = len + sizeof (struct tree_string); + +#ifdef GATHER_STATISTICS + tree_node_counts[(int) c_kind]++; + tree_node_sizes[(int) c_kind] += length; +#endif + + s = ggc_alloc_tree (length); + memset (s, 0, sizeof (struct tree_common)); + TREE_SET_CODE (s, STRING_CST); TREE_STRING_LENGTH (s) = len; - TREE_STRING_POINTER (s) = ggc_alloc_string (str, len); + memcpy ((char *) TREE_STRING_POINTER (s), str, len); + ((char *) TREE_STRING_POINTER (s))[len] = '\0'; return s; } |