From: Richard Sandiford Date: Thu, 19 Dec 2019 13:21:54 +0000 (+0000) Subject: Don't mangle attributes that have a space in their name X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ed0eca5e631a1652c42a7f91b6c557aea887e1ce;p=gcc.git Don't mangle attributes that have a space in their name The SVE port needs to maintain a different type identity for GNU vectors and "SVE vectors" even during LTO, since the types use different ABIs. The easiest way of doing that seemed to be to use type attributes. However, these type attributes shouldn't be user-facing; they're just a convenient way of representing the types internally in GCC. There are already several internal-only attributes, such as "fn spec" and "omp declare simd". They're distinguished from normal user-facing attributes by having a space in their name, which means that it isn't possible to write them directly in C or C++. Taking the same approach mostly works well for SVE. The only snag I've hit so far is that the new attribute needs to (and only exists to) affect type identity. This means that it would normally get included in mangled names, to distinguish it from types without the attribute. However, the SVE ABI specifies a separate mangling for SVE vector types, rather than using an attribute mangling + a normal vector mangling. So we need some way of suppressing the attribute mangling for this case. There are currently no other target-independent or target-specific internal-only attributes that affect type identity, so this patch goes for the simplest fix of skipping mangling for attributes whose names contain a space. Other options I thought about were: (1) Also make sure that targetm.mangled_type returns nonnull. (2) Check directly for the target-specific name. (3) Add a new target hook. (4) Add new information to attribute_spec. This would be very invasive at this stage, but maybe we should consider replacing all the boolean fields with flags? That should make the tables slightly easier to read and would make adding new flags much simpler in future. 2019-12-19 Richard Sandiford gcc/cp/ * mangle.c (write_CV_qualifiers_for_type): Don't mangle attributes that contain a space. From-SVN: r279569 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 19e1b881e2d..e66f1e0776a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-12-19 Richard Sandiford + + * mangle.c (write_CV_qualifiers_for_type): Don't mangle attributes + that contain a space. + 2019-12-18 Jason Merrill PR c++/91165 follow-on tweak diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 88c5fa2c622..b13af39b2e7 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2377,6 +2377,11 @@ write_CV_qualifiers_for_type (const tree type) tree name = get_attribute_name (a); const attribute_spec *as = lookup_attribute_spec (name); if (as && as->affects_type_identity + /* Skip internal-only attributes, which are distinguished from + others by having a space. At present, all internal-only + attributes that affect type identity are target-specific + and are handled by targetm.mangle_type instead. */ + && !strchr (IDENTIFIER_POINTER (name), ' ') && !is_attribute_p ("transaction_safe", name) && !is_attribute_p ("abi_tag", name)) vec.safe_push (a);