Commit b0ad2d78 by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Invoke global_bindings_p last when possible.

	* gcc-interface/decl.c (gnat_to_gnu_entity): Invoke global_bindings_p
	last when possible.  Do not call elaborate_expression_2 on offsets in
	local record types and avoid useless processing for constant offsets.

From-SVN: r238001
parent f723a43c
2016-07-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Invoke global_bindings_p
last when possible. Do not call elaborate_expression_2 on offsets in
local record types and avoid useless processing for constant offsets.
2016-07-04 Arnaud Charlet <charlet@adacore.com> 2016-07-04 Arnaud Charlet <charlet@adacore.com>
* gnat_rm.texi, gnat_ugn.texi, * gnat_rm.texi, gnat_ugn.texi,
......
...@@ -798,10 +798,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -798,10 +798,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
mutable_p = true; mutable_p = true;
} }
/* If we are at global level and the size isn't constant, call /* If the size isn't constant and we are at global level, call
elaborate_expression_1 to make a variable for it rather than elaborate_expression_1 to make a variable for it rather than
calculating it each time. */ calculating it each time. */
if (global_bindings_p () && !TREE_CONSTANT (gnu_size)) if (!TREE_CONSTANT (gnu_size) && global_bindings_p ())
gnu_size = elaborate_expression_1 (gnu_size, gnat_entity, gnu_size = elaborate_expression_1 (gnu_size, gnat_entity,
"SIZE", definition, false); "SIZE", definition, false);
} }
...@@ -1366,10 +1366,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -1366,10 +1366,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
than the largest stack alignment the back-end can honor, resort to than the largest stack alignment the back-end can honor, resort to
a variable of "aligning type". */ a variable of "aligning type". */
if (definition if (definition
&& !global_bindings_p () && TYPE_ALIGN (gnu_type) > BIGGEST_ALIGNMENT
&& !static_flag
&& !imported_p && !imported_p
&& TYPE_ALIGN (gnu_type) > BIGGEST_ALIGNMENT) && !static_flag
&& !global_bindings_p ())
{ {
/* Create the new variable. No need for extra room before the /* Create the new variable. No need for extra room before the
aligned field as this is in automatic storage. */ aligned field as this is in automatic storage. */
...@@ -2679,10 +2679,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -2679,10 +2679,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
TYPE_STUB_DECL (gnu_type) TYPE_STUB_DECL (gnu_type)
= create_type_stub_decl (gnu_entity_name, gnu_type); = create_type_stub_decl (gnu_entity_name, gnu_type);
/* If we are at file level and this is a multi-dimensional array, /* If this is a multi-dimensional array and we are at global level,
we need to make a variable corresponding to the stride of the we need to make a variable corresponding to the stride of the
inner dimensions. */ inner dimensions. */
if (global_bindings_p () && ndim > 1) if (ndim > 1 && global_bindings_p ())
{ {
tree gnu_arr_type; tree gnu_arr_type;
...@@ -4587,10 +4587,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -4587,10 +4587,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
a constant or self-referential, call elaborate_expression_1 to a constant or self-referential, call elaborate_expression_1 to
make a variable for the size rather than calculating it each time. make a variable for the size rather than calculating it each time.
Handle both the RM size and the actual size. */ Handle both the RM size and the actual size. */
if (global_bindings_p () if (TYPE_SIZE (gnu_type)
&& TYPE_SIZE (gnu_type)
&& !TREE_CONSTANT (TYPE_SIZE (gnu_type)) && !TREE_CONSTANT (TYPE_SIZE (gnu_type))
&& !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type))) && !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type))
&& global_bindings_p ())
{ {
tree size = TYPE_SIZE (gnu_type); tree size = TYPE_SIZE (gnu_type);
...@@ -4672,11 +4672,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -4672,11 +4672,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
} }
} }
/* If this is a record type or subtype, call elaborate_expression_2 on /* Similarly, if this is a record type or subtype at global level, call
any field position. Do this for both global and local types. elaborate_expression_2 on any field position. Skip any fields that
Skip any fields that we haven't made trees for to avoid problems with we haven't made trees for to avoid problems with class-wide types. */
class wide types. */ if (IN (kind, Record_Kind) && global_bindings_p ())
if (IN (kind, Record_Kind))
for (gnat_temp = First_Entity (gnat_entity); Present (gnat_temp); for (gnat_temp = First_Entity (gnat_entity); Present (gnat_temp);
gnat_temp = Next_Entity (gnat_temp)) gnat_temp = Next_Entity (gnat_temp))
if (Ekind (gnat_temp) == E_Component && present_gnu_tree (gnat_temp)) if (Ekind (gnat_temp) == E_Component && present_gnu_tree (gnat_temp))
...@@ -4685,7 +4684,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -4685,7 +4684,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* ??? For now, store the offset as a multiple of the alignment /* ??? For now, store the offset as a multiple of the alignment
in bytes so that we can see the alignment from the tree. */ in bytes so that we can see the alignment from the tree. */
if (!CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (gnu_field))) if (!TREE_CONSTANT (DECL_FIELD_OFFSET (gnu_field))
&& !CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (gnu_field)))
{ {
DECL_FIELD_OFFSET (gnu_field) DECL_FIELD_OFFSET (gnu_field)
= elaborate_expression_2 (DECL_FIELD_OFFSET (gnu_field), = elaborate_expression_2 (DECL_FIELD_OFFSET (gnu_field),
...@@ -4696,8 +4696,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -4696,8 +4696,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* ??? The context of gnu_field is not necessarily gnu_type /* ??? The context of gnu_field is not necessarily gnu_type
so the MULT_EXPR node built above may not be marked by so the MULT_EXPR node built above may not be marked by
the call to create_type_decl below. */ the call to create_type_decl below. */
if (global_bindings_p ()) MARK_VISITED (DECL_FIELD_OFFSET (gnu_field));
MARK_VISITED (DECL_FIELD_OFFSET (gnu_field));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment