Jakub Jelinek <ja...@redhat.com> writes:
> On Wed, Apr 29, 2020 at 10:57:24AM +0100, Richard Sandiford wrote:
>> This patch makes the ABI code ignore zero-sized [[no_unique_address]]
>> fields when deciding whether something is a HFA or HVA.
>
> As you use cxx17_empty_base_field_p, can you please remove the FIXME
> in calls.h because it then can't go away, and perhaps update it to
> test DECL_ARTIFICIAL (field) instead (or in addition to no attribute,
> with with DECL_ARTIFICIAL first)?

Sure, how's this?  I added back the RECORD_OR_UNION_TYPE_P test too
for good measure :-)

Only lightly tested on aarch64-linux-gnu and aarch64_be-elf so far.

Richard


2020-04-29  Richard Sandiford  <richard.sandif...@arm.com>

gcc/
        * calls.h (cxx17_empty_base_field_p): Turn into a function declaration.
        * calls.c (cxx17_empty_base_field_p): New function.  Check
        DECL_ARTIFICIAL and RECORD_OR_UNION_TYPE_P in addition to the
        previous checks.
---
 gcc/calls.c | 15 +++++++++++++++
 gcc/calls.h |  5 +----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gcc/calls.h b/gcc/calls.h
index e1c944efbb6..4ee49360777 100644
--- a/gcc/calls.h
+++ b/gcc/calls.h
@@ -135,9 +135,6 @@ extern tree get_attr_nonstring_decl (tree, tree * = NULL);
 extern void maybe_warn_nonstring_arg (tree, tree);
 extern bool get_size_range (tree, tree[2], bool = false);
 extern rtx rtx_for_static_chain (const_tree, bool);
-/* FIXME: Remove after all backends are converted.  */
-#define cxx17_empty_base_field_p(t) \
-  (DECL_FIELD_ABI_IGNORED (t)                                          \
-   && !lookup_attribute ("no_unique_address", DECL_ATTRIBUTES (t)))
+extern bool cxx17_empty_base_field_p (const_tree);
 
 #endif // GCC_CALLS_H
diff --git a/gcc/calls.c b/gcc/calls.c
index 5bd922779af..8041388c1d2 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -6261,5 +6261,20 @@ must_pass_va_arg_in_stack (tree type)
   return targetm.calls.must_pass_in_stack (arg);
 }
 
+/* Return true if FIELD is the C++17 empty base field that should
+   be ignored for ABI calling convention decisions in order to
+   maintain ABI compatibility between C++14 and earlier, which doesn't
+   add this FIELD to classes with empty bases, and C++17 and later
+   which does.  */
+
+bool
+cxx17_empty_base_field_p (const_tree field)
+{
+  return (DECL_FIELD_ABI_IGNORED (field)
+         && DECL_ARTIFICIAL (field)
+         && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
+         && !lookup_attribute ("no_unique_address", DECL_ATTRIBUTES (field)));
+}
+
 /* Tell the garbage collector about GTY markers in this source file.  */
 #include "gt-calls.h"

Reply via email to