* [Ada] Fix PR bootstrap/109510
@ 2023-04-14 18:18 Eric Botcazou
2023-04-15 17:39 ` Eric Botcazou
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2023-04-14 18:18 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 658 bytes --]
This is the build failure of the Ada runtime for Aarch64 targets. The Aarch64
back-end now asserts that the main variant of scalar types has TYPE_USER_ALIGN
cleared, and that's not the case for scalar types declared with a confirming
alignment clause in Ada.
Tested on Aarch64/Linux by Richard S. (thanks!) and on x86-64/Linux by me, and
applied on the mainline.
2023-04-14 Eric Botcazou <ebotcazou@adacore.com>
PR bootstrap/109510
* gcc-interface/decl.cc (gnat_to_gnu_entity) <types>: Reset align
to zero if its value is equal to TYPE_ALIGN and the type is scalar.
Set TYPE_USER_ALIGN on the type only if align is positive.
--
Eric Botcazou
[-- Attachment #2: pr109510.diff --]
[-- Type: text/x-patch, Size: 1590 bytes --]
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index d24adf33601..851a6745f77 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -4364,13 +4364,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* If the alignment has not already been processed and this is not
an unconstrained array type, see if an alignment is specified.
If not, we pick a default alignment for atomic objects. */
- if (align != 0 || TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE)
+ if (align > 0 || TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE)
;
else if (Known_Alignment (gnat_entity))
{
align = validate_alignment (Alignment (gnat_entity), gnat_entity,
TYPE_ALIGN (gnu_type));
+ /* Treat confirming clauses on scalar types like the default. */
+ if (align == TYPE_ALIGN (gnu_type) && !AGGREGATE_TYPE_P (gnu_type))
+ align = 0;
+
/* Warn on suspiciously large alignments. This should catch
errors about the (alignment,byte)/(size,bit) discrepancy. */
if (align > BIGGEST_ALIGNMENT && Has_Alignment_Clause (gnat_entity))
@@ -4666,7 +4670,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
TYPE_BY_REFERENCE_P (gnu_type) = 1;
/* Record whether an alignment clause was specified. */
- if (Present (Alignment_Clause (gnat_entity)))
+ if (align > 0 && Present (Alignment_Clause (gnat_entity)))
TYPE_USER_ALIGN (gnu_type) = 1;
/* Record whether a pragma Universal_Aliasing was specified. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Ada] Fix PR bootstrap/109510
2023-04-14 18:18 [Ada] Fix PR bootstrap/109510 Eric Botcazou
@ 2023-04-15 17:39 ` Eric Botcazou
0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2023-04-15 17:39 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
> Tested on Aarch64/Linux by Richard S. (thanks!) and on x86-64/Linux by me,
> and applied on the mainline.
It turns out that it slightly broke the x86/Linux compiler, which is not yet
an acceptable trade-off. Adjusted like this, tested on x86[_64]/Linux, this
should not change anything for Aarch64 in particular.
PR bootstrap/109510
* gcc-interface/decl.cc (gnat_to_gnu_entity) <types>: Do not reset
align to zero in any case. Set TYPE_USER_ALIGN on the type only if
it is an aggregate type, or else a type whose default alignment is
specifically capped on selected platforms.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2407 bytes --]
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 851a6745f77..20f43de9ea9 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -4371,10 +4371,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
align = validate_alignment (Alignment (gnat_entity), gnat_entity,
TYPE_ALIGN (gnu_type));
- /* Treat confirming clauses on scalar types like the default. */
- if (align == TYPE_ALIGN (gnu_type) && !AGGREGATE_TYPE_P (gnu_type))
- align = 0;
-
/* Warn on suspiciously large alignments. This should catch
errors about the (alignment,byte)/(size,bit) discrepancy. */
if (align > BIGGEST_ALIGNMENT && Has_Alignment_Clause (gnat_entity))
@@ -4657,6 +4653,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* If this is not an unconstrained array type, set some flags. */
if (TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE)
{
+ bool align_clause;
+
/* Record the property that objects of tagged types are guaranteed to
be properly aligned. This is necessary because conversions to the
class-wide type are translated into conversions to the root type,
@@ -4669,8 +4667,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
if (is_by_ref && !VOID_TYPE_P (gnu_type))
TYPE_BY_REFERENCE_P (gnu_type) = 1;
- /* Record whether an alignment clause was specified. */
- if (align > 0 && Present (Alignment_Clause (gnat_entity)))
+ /* Record whether an alignment clause was specified. At this point
+ scalar types with a non-confirming clause have been wrapped into
+ a record type, so only scalar types with a confirming clause are
+ left untouched; we do not set the flag on them except if they are
+ types whose default alignment is specifically capped in order not
+ to lose the specified alignment. */
+ if ((AGGREGATE_TYPE_P (gnu_type)
+ && Present (Alignment_Clause (gnat_entity)))
+ || (double_float_alignment > 0
+ && is_double_float_or_array (gnat_entity, &align_clause)
+ && align_clause)
+ || (double_scalar_alignment > 0
+ && is_double_scalar_or_array (gnat_entity, &align_clause)
+ && align_clause))
TYPE_USER_ALIGN (gnu_type) = 1;
/* Record whether a pragma Universal_Aliasing was specified. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-15 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 18:18 [Ada] Fix PR bootstrap/109510 Eric Botcazou
2023-04-15 17:39 ` Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).