/* The C standard specifically allows aliasing between signed and
unsigned variants of the same type. We treat the signed
variant as canonical. */
- if ((TREE_CODE (t) == INTEGER_TYPE || TREE_CODE (t) == BITINT_TYPE)
- && TYPE_UNSIGNED (t))
- {
- tree t1 = c_common_signed_type (t);
-
- /* t1 == t can happen for boolean nodes which are always unsigned. */
- if (t1 != t)
- return get_alias_set (t1);
+ if (TREE_CODE (t) == INTEGER_TYPE || TREE_CODE (t) == BITINT_TYPE)
+ {
+ /* For normal INTEGER_TYPEs (except ones built by
+ build_nonstandard_integer_type), both signed and unsigned variants
+ of the type are always reachable from GTY roots, so just calling
+ get_alias_set on the signed type is ok. For BITINT_TYPE and
+ non-standard INTEGER_TYPEs, only unsigned could be used and the
+ corresponding signed type could be created on demand and garbage
+ collected as unused, so the alias set of unsigned type could keep
+ changing.
+ Avoid that by remembering the signed type alias set in
+ TYPE_ALIAS_SET and also when being asked about !TYPE_UNSIGNED
+ check if there isn't a corresponding unsigned type with
+ TYPE_ALIAS_SET_KNOWN_P. */
+ if (TYPE_UNSIGNED (t))
+ {
+ /* There is no signed _BitInt(1). */
+ if (TREE_CODE (t) == BITINT_TYPE && TYPE_PRECISION (t) == 1)
+ return -1;
+ tree t1 = c_common_signed_type (t);
+ gcc_checking_assert (t != t1);
+ TYPE_ALIAS_SET (t) = get_alias_set (t1);
+ return TYPE_ALIAS_SET (t);
+ }
+ else
+ {
+ tree t1 = c_common_unsigned_type (t);
+ gcc_checking_assert (t != t1);
+ if (TYPE_ALIAS_SET_KNOWN_P (t1))
+ {
+ TYPE_ALIAS_SET (t) = TYPE_ALIAS_SET (t1);
+ return TYPE_ALIAS_SET (t);
+ }
+ }
}
return -1;
else
fixup_signed_type (itype);
- inchash::hash hstate;
- inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
- ret = type_hash_canon (hstate.end (), itype);
+ hashval_t hash = type_hash_canon_hash (itype);
+ ret = type_hash_canon (hash, itype);
if (precision <= MAX_INT_CACHED_PREC)
(*bitint_type_cache)[precision + unsignedp] = ret;