diff options
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/volatile6.adb | 20 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/volatile7.adb | 24 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/volatile8.adb | 22 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/volatile9.adb | 20 | ||||
-rw-r--r-- | gcc/tree-sra.c | 14 |
9 files changed, 136 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4fe0b105bf0..d85c2bb78ff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-06-18 Eric Botcazou <ebotcazou@adacore.com> + + * tree-sra.c (type_internals_preclude_sra_p) <ARRAY_TYPE>: Return true + if the element type is volatile. + 2011-06-18 Jan Hubicka <jh@suse.cz> * lto-symtab.c (lto_varpool_replace_node): Remove code handling @@ -123,7 +128,7 @@ (arm_legitimate_ldrd_p): New function. (arm_output_ldrd): New function. -2010-06-16 Joern Rennecke <joern.rennecke@embecosm.com> +2011-06-16 Joern Rennecke <joern.rennecke@embecosm.com> PR middle-end/46500 * doc/tm.texi.in: Update Copyright date. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index fdba3c4ea1e..c27f132e0c4 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,13 @@ 2011-06-18 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_component_type): Use GNAT_TYPE + local variable throughout. Remove useless call to Base_Type. + (gnat_to_gnu_field): Use GNAT_FIELD_TYPE local variable throughout. + Take it also into account for the volatileness of the field. Set the + TREE_SIDE_EFFECTS flag as well in this case. Reorder some warnings. + +2011-06-18 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/trans.c (Identifier_to_gnu): Don't set TREE_THIS_NOTRAP on a dereference built for a by-ref object if it has an address clause. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 3803c2d5cee..1f9083a454e 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -5229,7 +5229,8 @@ static tree gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, bool debug_info_p) { - tree gnu_type = gnat_to_gnu_type (Component_Type (gnat_array)); + const Entity_Id gnat_type = Component_Type (gnat_array); + tree gnu_type = gnat_to_gnu_type (gnat_type); tree gnu_comp_size; /* Try to get a smaller form of the component if needed. */ @@ -5237,7 +5238,7 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, || Has_Component_Size_Clause (gnat_array)) && !Is_Bit_Packed_Array (gnat_array) && !Has_Aliased_Components (gnat_array) - && !Strict_Alignment (Component_Type (gnat_array)) + && !Strict_Alignment (gnat_type) && TREE_CODE (gnu_type) == RECORD_TYPE && !TYPE_FAT_POINTER_P (gnu_type) && host_integerp (TYPE_SIZE (gnu_type), 1)) @@ -5301,7 +5302,7 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, debug_info_p, gnat_array); } - if (Has_Volatile_Components (Base_Type (gnat_array))) + if (Has_Volatile_Components (gnat_array)) gnu_type = build_qualified_type (gnu_type, TYPE_QUALS (gnu_type) | TYPE_QUAL_VOLATILE); @@ -6716,12 +6717,16 @@ static tree gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, bool definition, bool debug_info_p) { + const Entity_Id gnat_field_type = Etype (gnat_field); + tree gnu_field_type = gnat_to_gnu_type (gnat_field_type); tree gnu_field_id = get_entity_name (gnat_field); - tree gnu_field_type = gnat_to_gnu_type (Etype (gnat_field)); tree gnu_field, gnu_size, gnu_pos; + bool is_volatile + = (Treat_As_Volatile (gnat_field) || Treat_As_Volatile (gnat_field_type)); bool needs_strict_alignment - = (Is_Aliased (gnat_field) || Strict_Alignment (Etype (gnat_field)) - || Treat_As_Volatile (gnat_field)); + = (is_volatile + || Is_Aliased (gnat_field) + || Strict_Alignment (gnat_field_type)); /* If this field requires strict alignment, we cannot pack it because it would very likely be under-aligned in the record. */ @@ -6737,7 +6742,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, gnu_size = validate_size (Esize (gnat_field), gnu_field_type, gnat_field, FIELD_DECL, false, true); else if (packed == 1) - gnu_size = validate_size (RM_Size (Etype (gnat_field)), gnu_field_type, + gnu_size = validate_size (RM_Size (gnat_field_type), gnu_field_type, gnat_field, FIELD_DECL, false, true); else gnu_size = NULL_TREE; @@ -6829,7 +6834,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, if (gnu_size && !operand_equal_p (gnu_size, TYPE_SIZE (gnu_field_type), 0)) { - if (Is_Atomic (gnat_field) || Is_Atomic (Etype (gnat_field))) + if (Is_Atomic (gnat_field) || Is_Atomic (gnat_field_type)) post_error_ne_tree ("atomic field& must be natural size of type{ (^)}", Last_Bit (Component_Clause (gnat_field)), gnat_field, @@ -6841,7 +6846,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, Last_Bit (Component_Clause (gnat_field)), gnat_field, TYPE_SIZE (gnu_field_type)); - else if (Strict_Alignment (Etype (gnat_field))) + else if (Strict_Alignment (gnat_field_type)) post_error_ne_tree ("size of & with aliased or tagged components not ^ bits", Last_Bit (Component_Clause (gnat_field)), gnat_field, @@ -6854,19 +6859,19 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, (TRUNC_MOD_EXPR, gnu_pos, bitsize_int (TYPE_ALIGN (gnu_field_type))))) { - if (Is_Aliased (gnat_field)) + if (is_volatile) post_error_ne_num - ("position of aliased field& must be multiple of ^ bits", + ("position of volatile field& must be multiple of ^ bits", First_Bit (Component_Clause (gnat_field)), gnat_field, TYPE_ALIGN (gnu_field_type)); - else if (Treat_As_Volatile (gnat_field)) + else if (Is_Aliased (gnat_field)) post_error_ne_num - ("position of volatile field& must be multiple of ^ bits", + ("position of aliased field& must be multiple of ^ bits", First_Bit (Component_Clause (gnat_field)), gnat_field, TYPE_ALIGN (gnu_field_type)); - else if (Strict_Alignment (Etype (gnat_field))) + else if (Strict_Alignment (gnat_field_type)) post_error_ne_num ("position of & with aliased or tagged components not multiple of ^ bits", First_Bit (Component_Clause (gnat_field)), gnat_field, @@ -6901,7 +6906,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, if (TREE_CODE (gnu_field_type) == RECORD_TYPE && !gnu_size && CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_field_type)) - && !Is_Constrained (Underlying_Type (Etype (gnat_field)))) + && !Is_Constrained (Underlying_Type (gnat_field_type))) { gnu_size = max_size (TYPE_SIZE (gnu_field_type), true); packed = 0; @@ -6953,7 +6958,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, = create_field_decl (gnu_field_id, gnu_field_type, gnu_record_type, gnu_size, gnu_pos, packed, Is_Aliased (gnat_field)); Sloc_to_locus (Sloc (gnat_field), &DECL_SOURCE_LOCATION (gnu_field)); - TREE_THIS_VOLATILE (gnu_field) = Treat_As_Volatile (gnat_field); + TREE_THIS_VOLATILE (gnu_field) = TREE_SIDE_EFFECTS (gnu_field) = is_volatile; if (Ekind (gnat_field) == E_Discriminant) DECL_DISCRIMINANT_NUMBER (gnu_field) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dcd49190075..907b94d74f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2011-06-18 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/volatile6.adb: New test. + * gnat.dg/volatile7.adb: Likewise. + * gnat.dg/volatile8.adb: Likewise. + * gnat.dg/volatile9.adb: Likewise. + +2011-06-18 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/constant3.adb: New test. 2011-06-18 Janne Blomqvist <jb@gcc.gnu.org> diff --git a/gcc/testsuite/gnat.dg/volatile6.adb b/gcc/testsuite/gnat.dg/volatile6.adb new file mode 100644 index 00000000000..aeaacb028f7 --- /dev/null +++ b/gcc/testsuite/gnat.dg/volatile6.adb @@ -0,0 +1,20 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fdump-tree-optimized" } + +function Volatile6 return Integer is + + type Vol is new Integer; + pragma Volatile (Vol); + + V : Vol := 0; + +begin + for J in 1 .. 10 loop + V := V + 1; + end loop; + + return Integer (V); +end; + +-- { dg-final { scan-tree-dump "goto" "optimized" } } +-- { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/gnat.dg/volatile7.adb b/gcc/testsuite/gnat.dg/volatile7.adb new file mode 100644 index 00000000000..d0eb48ffee6 --- /dev/null +++ b/gcc/testsuite/gnat.dg/volatile7.adb @@ -0,0 +1,24 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fdump-tree-optimized" } + +function Volatile7 return Integer is + + type Vol is new Integer; + pragma Volatile (Vol); + + type R is record + X : Vol := 0; + end record; + + V : R; + +begin + for J in 1 .. 10 loop + V.X := V.X + 1; + end loop; + + return Integer (V.X); +end; + +-- { dg-final { scan-tree-dump "goto" "optimized" } } +-- { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/gnat.dg/volatile8.adb b/gcc/testsuite/gnat.dg/volatile8.adb new file mode 100644 index 00000000000..83f7488580e --- /dev/null +++ b/gcc/testsuite/gnat.dg/volatile8.adb @@ -0,0 +1,22 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fdump-tree-optimized" } + +function Volatile8 return Integer is + + type Vol is new Integer; + pragma Volatile (Vol); + + type A is array (1..4) of Vol; + + V : A := (others => 0); + +begin + for J in 1 .. 10 loop + V(1) := V(1) + 1; + end loop; + + return Integer (V(1)); +end; + +-- { dg-final { scan-tree-dump "goto" "optimized" } } +-- { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/gnat.dg/volatile9.adb b/gcc/testsuite/gnat.dg/volatile9.adb new file mode 100644 index 00000000000..52b55aee23a --- /dev/null +++ b/gcc/testsuite/gnat.dg/volatile9.adb @@ -0,0 +1,20 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fdump-tree-optimized" } + +function Volatile9 return Integer is + + type A is array (1..4) of Integer; + pragma Volatile_Components (A); + + V : A := (others => 0); + +begin + for J in 1 .. 10 loop + V(1) := V(1) + 1; + end loop; + + return V(1); +end; + +-- { dg-final { scan-tree-dump "goto" "optimized" } } +-- { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 28eba433dad..322abb570a4 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -671,8 +671,7 @@ type_internals_preclude_sra_p (tree type) && int_bit_position (fld) % BITS_PER_UNIT != 0)) return true; - if (AGGREGATE_TYPE_P (ft) - && type_internals_preclude_sra_p (ft)) + if (AGGREGATE_TYPE_P (ft) && type_internals_preclude_sra_p (ft)) return true; } @@ -681,10 +680,13 @@ type_internals_preclude_sra_p (tree type) case ARRAY_TYPE: et = TREE_TYPE (type); - if (AGGREGATE_TYPE_P (et)) - return type_internals_preclude_sra_p (et); - else - return false; + if (TYPE_VOLATILE (et)) + return true; + + if (AGGREGATE_TYPE_P (et) && type_internals_preclude_sra_p (et)) + return true; + + return false; default: return false; |