diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2009-04-23 16:40:55 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2009-04-23 16:40:55 +0000 |
commit | bbaba73f06d6ebd6e5b3ed96e7fd40537e3fa489 (patch) | |
tree | c50f816477650b4e3cbb25b84c72aae959f07b1b /gcc/ada | |
parent | 3682dc97d6bf818e4c95c734e4d5588a9d9a4cda (diff) | |
download | gcc-bbaba73f06d6ebd6e5b3ed96e7fd40537e3fa489.zip gcc-bbaba73f06d6ebd6e5b3ed96e7fd40537e3fa489.tar.gz gcc-bbaba73f06d6ebd6e5b3ed96e7fd40537e3fa489.tar.bz2 |
gimplify.c (gimplify_modify_expr_rhs): Do not do a direct assignment from the constructor either if the target is volatile.
* gimplify.c (gimplify_modify_expr_rhs) <VAR_DECL>: Do not do a direct
assignment from the constructor either if the target is volatile.
ada/
* einfo.ads (Is_True_Constant): Lift restriction on atomic objects.
* sinfo.ads (Object Declaration): Likewise.
(Assignment Statement): Likewise.
* freeze.adb (Expand_Atomic_Aggregate): Remove useless test.
Do not force Is_True_Constant to false on the temporary.
(Freeze_Entity): Do not force Is_True_Constant to false on names on
the RHS of object declarations.
* gcc-interface/trans.c (lvalue_required_p) <N_Object_Declaration>:
New case. Return 1 if the object is atomic.
<N_Assignment_Statement>: Likewise.
From-SVN: r146652
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/ada/einfo.ads | 10 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 43 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 12 | ||||
-rw-r--r-- | gcc/ada/sinfo.ads | 14 |
5 files changed, 36 insertions, 56 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 90e7821..dd21b44 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,18 @@ 2009-04-23 Eric Botcazou <ebotcazou@adacore.com> + * einfo.ads (Is_True_Constant): Lift restriction on atomic objects. + * sinfo.ads (Object Declaration): Likewise. + (Assignment Statement): Likewise. + * freeze.adb (Expand_Atomic_Aggregate): Remove useless test. + Do not force Is_True_Constant to false on the temporary. + (Freeze_Entity): Do not force Is_True_Constant to false on names on + the RHS of object declarations. + * gcc-interface/trans.c (lvalue_required_p) <N_Object_Declaration>: + New case. Return 1 if the object is atomic. + <N_Assignment_Statement>: Likewise. + +2009-04-23 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Modular_Integer_Subtype> For packed array types, make the original array type a parallel type for the modular type and its JM wrapper if the type is bit-packed. diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index c0ee644..35c8351 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -2615,16 +2615,6 @@ package Einfo is -- that the constant was not modified by generated code (e.g. to set a -- discriminant in an init proc). Assignments by user or generated code -- will reset this flag. --- --- Note: there is one situation in which the back end does not permit --- this flag to be set, even if no assignments are generated. This is --- the case of an object of a record or array type which is initialized --- with an aggregate, and is itself used as the expression initializing --- an atomic object, or the right hand side of an assignment to an atomic --- object. In this case the object must not have Is_True_Constant set, --- even though no assignments are generated (the reason for this is that --- the back end must not optimize the object away, because that would --- violate the restriction on aggregates in these positions). -- Is_Type (synthesized) -- Applies to all entities, true for a type entity diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index a74a6c2..7866432 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1120,7 +1120,6 @@ package body Freeze is if (Nkind (Parent (E)) = N_Object_Declaration or else Nkind (Parent (E)) = N_Assignment_Statement) and then Comes_From_Source (Parent (E)) - and then Nkind (E) = N_Aggregate then Temp := Make_Defining_Identifier (Loc, @@ -1136,13 +1135,6 @@ package body Freeze is Set_Expression (Parent (E), New_Occurrence_Of (Temp, Loc)); - -- To prevent the temporary from being constant-folded (which would - -- lead to the same piecemeal assignment on the original target) - -- indicate to the back-end that the temporary is a variable with - -- real storage. See description of this flag in Einfo, and the notes - -- on N_Assignment_Statement and N_Object_Declaration in Sinfo. - - Set_Is_True_Constant (Temp, False); end if; end Expand_Atomic_Aggregate; @@ -2295,39 +2287,18 @@ package body Freeze is Set_Encoded_Interface_Name (E, Get_Default_External_Name (E)); - -- Special processing for atomic objects appearing in object decls + -- If entity is an atomic object appearing in a declaration and + -- the expression is an aggregate, assign it to a temporary to + -- ensure that the actual assignment is done atomically rather + -- than component-wise (the assignment to the temp may be done + -- component-wise, but that is harmless). elsif Is_Atomic (E) and then Nkind (Parent (E)) = N_Object_Declaration and then Present (Expression (Parent (E))) + and then Nkind (Expression (Parent (E))) = N_Aggregate then - declare - Expr : constant Node_Id := Expression (Parent (E)); - - begin - -- If expression is an aggregate, assign to a temporary to - -- ensure that the actual assignment is done atomically rather - -- than component-wise (the assignment to the temp may be done - -- component-wise, but that is harmless). - - if Nkind (Expr) = N_Aggregate then - Expand_Atomic_Aggregate (Expr, Etype (E)); - - -- If the expression is a reference to a record or array object - -- entity, then reset Is_True_Constant to False so that the - -- compiler will not optimize away the intermediate object, - -- which we need in this case for the same reason (to ensure - -- that the actual assignment is atomic, rather than - -- component-wise). - - elsif Is_Entity_Name (Expr) - and then (Is_Record_Type (Etype (Expr)) - or else - Is_Array_Type (Etype (Expr))) - then - Set_Is_True_Constant (Entity (Expr), False); - end if; - end; + Expand_Atomic_Aggregate (Expression (Parent (E)), Etype (E)); end if; -- For a subprogram, freeze all parameter types and also the return diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 275017c..de6ac0b 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -723,6 +723,18 @@ lvalue_required_p (Node_Id gnat_node, tree gnu_type, int aliased) (Underlying_Type (Etype (Name (gnat_parent)))) || Nkind (Name (gnat_parent)) == N_Identifier); + case N_Object_Declaration: + /* We cannot use a constructor if this is an atomic object because + the actual assignment might end up being done component-wise. */ + return Is_Composite_Type (Underlying_Type (Etype (gnat_node))) + && Is_Atomic (Defining_Entity (gnat_parent)); + + case N_Assignment_Statement: + /* We cannot use a constructor if the LHS is an atomic object because + the actual assignment might end up being done component-wise. */ + return Is_Composite_Type (Underlying_Type (Etype (gnat_node))) + && Is_Atomic (Entity (Name (gnat_parent))); + default: return 0; } diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index d45b4b0..5aae9c0 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -2152,11 +2152,8 @@ package Sinfo is -- Note: the back end places some restrictions on the form of the -- Expression field. If the object being declared is Atomic, then -- the Expression may not have the form of an aggregate (since this - -- might cause the back end to generate separate assignments). It - -- also cannot be a reference to an object marked as a true constant - -- (Is_True_Constant flag set), where the object is itself initialized - -- with an aggregate. If necessary the front end must generate an - -- extra temporary (with Is_True_Constant set False), and initialize + -- might cause the back end to generate separate assignments). In this + -- case the front end must generate an extra temporary and initialize -- this temporary as required (the temporary itself is not atomic). -- Note: there is not node kind for object definition. Instead, the @@ -3848,11 +3845,8 @@ package Sinfo is -- Note: the back end places some restrictions on the form of the -- Expression field. If the object being assigned to is Atomic, then -- the Expression may not have the form of an aggregate (since this - -- might cause the back end to generate separate assignments). It - -- also cannot be a reference to an object marked as a true constant - -- (Is_True_Constant flag set), where the object is itself initialized - -- with an aggregate. If necessary the front end must generate an - -- extra temporary (with Is_True_Constant set False), and initialize + -- might cause the back end to generate separate assignments). In this + -- case the front end must generate an extra temporary and initialize -- this temporary as required (the temporary itself is not atomic). ----------------------- |