From: Jakub Jelinek Date: Fri, 5 May 2017 07:35:13 +0000 (+0200) Subject: tree.c (next_type_uid): Change type to unsigned. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56871768b4cf5c2fd82456e03ae2f83a9789d2fb;p=gcc.git tree.c (next_type_uid): Change type to unsigned. * tree.c (next_type_uid): Change type to unsigned. (type_hash_canon): Decrement back next_type_uid if freeing a type node with the highest TYPE_UID. For INTEGER_TYPEs also ggc_free TYPE_MIN_VALUE, TYPE_MAX_VALUE and TYPE_CACHED_VALUES if possible. From-SVN: r247628 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fbb90a70f85..44df0d7ecdd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-05-05 Jakub Jelinek + + * tree.c (next_type_uid): Change type to unsigned. + (type_hash_canon): Decrement back next_type_uid if + freeing a type node with the highest TYPE_UID. For INTEGER_TYPEs + also ggc_free TYPE_MIN_VALUE, TYPE_MAX_VALUE and TYPE_CACHED_VALUES + if possible. + 2017-05-04 Martin Sebor * builtins.c: Fix a trivial typo in a comment. diff --git a/gcc/tree.c b/gcc/tree.c index 3bc6f1c284d..b76b521df61 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -151,7 +151,7 @@ static const char * const tree_node_kind_names[] = { /* Unique id for next decl created. */ static GTY(()) int next_decl_uid; /* Unique id for next type created. */ -static GTY(()) int next_type_uid = 1; +static GTY(()) unsigned next_type_uid = 1; /* Unique id for next debug decl created. Use negative numbers, to catch erroneous uses. */ static GTY(()) int next_debug_decl_uid; @@ -7188,6 +7188,22 @@ type_hash_canon (unsigned int hashcode, tree type) { tree t1 = ((type_hash *) *loc)->type; gcc_assert (TYPE_MAIN_VARIANT (t1) == t1); + if (TYPE_UID (type) + 1 == next_type_uid) + --next_type_uid; + /* Free also min/max values and the cache for integer + types. This can't be done in free_node, as LTO frees + those on its own. */ + if (TREE_CODE (type) == INTEGER_TYPE) + { + if (TYPE_MIN_VALUE (type) + && TREE_TYPE (TYPE_MIN_VALUE (type)) == type) + ggc_free (TYPE_MIN_VALUE (type)); + if (TYPE_MAX_VALUE (type) + && TREE_TYPE (TYPE_MAX_VALUE (type)) == type) + ggc_free (TYPE_MAX_VALUE (type)); + if (TYPE_CACHED_VALUES_P (type)) + ggc_free (TYPE_CACHED_VALUES (type)); + } free_node (type); return t1; }