]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Do not promote the alignment if this doesn't prevent...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 25 Sep 2011 15:42:00 +0000 (15:42 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 25 Sep 2011 15:42:00 +0000 (15:42 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not promote
the alignment if this doesn't prevent BLKmode access to the object.

From-SVN: r179167

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/frame_overflow.adb
gcc/testsuite/gnat.dg/frame_overflow.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/addr1.ads

index 3606791f1c42051d546493c2ec9355cb28c70354..03adb2a348e2febbf125d816b70d52121380cd0a 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not promote
+       the alignment if this doesn't prevent BLKmode access to the object.
+
 2011-09-24  Iain Sandoe  <iains@gcc.gnu.org>
 
        * gcc-interface/Makefile.in (darwin): Do not issue the
index a6bfd37c41f752cd7723d8884e2ba2b6d0954611..d96f68383eb92c2862835108ac496ab7dcea5393 100644 (file)
@@ -817,16 +817,30 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                    && No (Address_Clause (gnat_entity))))
            && TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST)
          {
-           /* No point in jumping through all the hoops needed in order
+           unsigned int size_cap, align_cap;
+
+           /* No point in promoting the alignment if this doesn't prevent
+              BLKmode access to the object, in particular block copy, as
+              this will for example disable the NRV optimization for it.
+              No point in jumping through all the hoops needed in order
               to support BIGGEST_ALIGNMENT if we don't really have to.
               So we cap to the smallest alignment that corresponds to
               a known efficient memory access pattern of the target.  */
-           unsigned int align_cap = Is_Atomic (gnat_entity)
-                                    ? BIGGEST_ALIGNMENT
-                                    : get_mode_alignment (ptr_mode);
+           if (Is_Atomic (gnat_entity))
+             {
+               size_cap = UINT_MAX;
+               align_cap = BIGGEST_ALIGNMENT;
+             }
+           else
+             {
+               size_cap = MAX_FIXED_MODE_SIZE;
+               align_cap = get_mode_alignment (ptr_mode);
+             }
 
            if (!host_integerp (TYPE_SIZE (gnu_type), 1)
-               || compare_tree_int (TYPE_SIZE (gnu_type), align_cap) >= 0)
+               || compare_tree_int (TYPE_SIZE (gnu_type), size_cap) > 0)
+             align = 0;
+           else if (compare_tree_int (TYPE_SIZE (gnu_type), align_cap) > 0)
              align = align_cap;
            else
              align = ceil_alignment (tree_low_cst (TYPE_SIZE (gnu_type), 1));
index fc9624f849d8a8f24ae535c2afc8f7cc117e2fb4..7bd46ae17b53daefe3e22bb3755e2bb14e5e3f4c 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/frame_overflow.ads: New.
+       * gnat.dg/frame_overflow.adb: Adjust.
+       * gnat.dg/specs/addr1.ads: Likewise.
+
 2011-09-25  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/tree-ssa/restrict2.C: New test.
index e1ff4d3653351503de4cf7054af96034c41240cf..1e7405fa5258c89751a79a3c959e9f7f22f65eb7 100644 (file)
@@ -1,27 +1,20 @@
 -- { dg-do compile }
 
-with System;
+package body Frame_Overflow is
 
-procedure frame_overflow is
-
-   type Bitpos_Range_T is range 1..2**(System.Word_Size-1)-1;
-   type Bitmap_Array_T is array (Bitpos_Range_T) of Boolean;
-
-   type Bitmap_T is record
-      Bits : Bitmap_Array_T := (others => False);
-   end record;
-
-   function
+   function -- { dg-error "too large" }
      Set_In (Bitmap : Bitmap_T; Bitpos : Bitpos_Range_T)  return Bitmap_T
    is
-      Result: Bitmap_T := Bitmap; -- { dg-error "Storage_Error" }
+      Result: Bitmap_T := Bitmap;
    begin
       Result.Bits (Bitpos) := True;
       return Result;
    end;
 
-   function Negate (Bitmap : Bitmap_T) return Bitmap_T is
-      Result: Bitmap_T; -- { dg-error "Storage_Error" }
+   function -- { dg-error "too large" }
+     Negate (Bitmap : Bitmap_T) return Bitmap_T
+   is
+      Result: Bitmap_T;
    begin
       for E in Bitpos_Range_T loop
         Result.Bits (E) := not Bitmap.Bits (E);
@@ -29,6 +22,4 @@ procedure frame_overflow is
       return Result;
   end;
 
-begin
-   null;
-end;
+end Frame_Overflow;
diff --git a/gcc/testsuite/gnat.dg/frame_overflow.ads b/gcc/testsuite/gnat.dg/frame_overflow.ads
new file mode 100644 (file)
index 0000000..898e37a
--- /dev/null
@@ -0,0 +1,17 @@
+with System;
+
+package Frame_Overflow is
+
+   type Bitpos_Range_T is range 1..2**(System.Word_Size-1)-1;
+   type Bitmap_Array_T is array (Bitpos_Range_T) of Boolean;
+
+   type Bitmap_T is record
+      Bits : Bitmap_Array_T := (others => False);
+   end record;
+
+   function
+     Set_In (Bitmap : Bitmap_T; Bitpos : Bitpos_Range_T)  return Bitmap_T;
+
+   function Negate (Bitmap : Bitmap_T) return Bitmap_T;
+
+end Frame_Overflow;
index 83d432cff58406635966f06e5cdd10cd6d2e0632..ed048f68ef3b59a5e71cf0d704c40dc3b10b9b3f 100644 (file)
@@ -15,7 +15,7 @@ package Addr1 is
   end record;
   for Rec2'Size use 64;
 
-  A: Arr (1 .. 12);
+  A: Arr (1 .. 4);
 
   Obj1: Rec1;
   for Obj1'Address use A'Address; -- { dg-bogus "alignment" }