diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2022-06-07 21:46:04 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-06 13:29:49 +0000 |
commit | 1141fbd71ea1782c6eac750cfed809f0706aaafc (patch) | |
tree | 45caefd943d0502d4ab25014c1459a99b77d19cc /gcc/ada/gcc-interface/decl.cc | |
parent | 40242ebb71ed7a03ab23349a893afe6140c512d1 (diff) | |
download | gcc-1141fbd71ea1782c6eac750cfed809f0706aaafc.zip gcc-1141fbd71ea1782c6eac750cfed809f0706aaafc.tar.gz gcc-1141fbd71ea1782c6eac750cfed809f0706aaafc.tar.bz2 |
[Ada] Improve code generated for aggregates of VFA type
This avoids using a full access for constants internally generated from
assignments of aggregates with a Volatile_Full_Access type.
gcc/ada/
* gcc-interface/gigi.h (simple_constant_p): Declare.
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Strip
the qualifiers from the type of a simple constant.
(simple_constant_p): New predicate.
* gcc-interface/trans.cc (node_is_atomic): Return true for objects
with atomic type except for simple constants.
(node_is_volatile_full_access): Return false for simple constants
with VFA type.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.cc')
-rw-r--r-- | gcc/ada/gcc-interface/decl.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 3f6b88a..99277f0 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -660,8 +660,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) like variables. */ if (definition && !gnu_expr - && No (Address_Clause (gnat_entity)) && !No_Initialization (gnat_decl) + && No (Address_Clause (gnat_entity)) && No (gnat_renamed_obj)) { gnu_decl = error_mark_node; @@ -781,6 +781,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (kind == E_Loop_Parameter) gnu_type = get_base_type (gnu_type); + /* If this is a simple constant, strip the qualifiers from its type, + since the constant represents only its value. */ + else if (simple_constant_p (gnat_entity)) + gnu_type = TYPE_MAIN_VARIANT (gnu_type); + /* Reject non-renamed objects whose type is an unconstrained array or any object whose type is a dummy type or void. */ if ((TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE @@ -9541,6 +9546,19 @@ promote_object_alignment (tree gnu_type, tree gnu_size, Entity_Id gnat_entity) return align; } +/* Return whether GNAT_ENTITY is a simple constant, i.e. it represents only + its value and reading it has no side effects. */ + +bool +simple_constant_p (Entity_Id gnat_entity) +{ + return Ekind (gnat_entity) == E_Constant + && Present (Constant_Value (gnat_entity)) + && !No_Initialization (gnat_entity) + && No (Address_Clause (gnat_entity)) + && No (Renamed_Object (gnat_entity)); +} + /* Verify that TYPE is something we can implement atomically. If not, issue an error for GNAT_ENTITY. COMPONENT_P is true if we are being called to process a component type. */ |