[Ada] Avoid unnecessarily overaligned access types
Eric Botcazou
ebotcazou@adacore.com
Sun Aug 19 14:17:00 GMT 2012
This changes the default alignment of all access types to that of access types
with standard size (Standard'Address_Size) on non-strict-alignment platforms.
This in particular means that access-to-unconstrained-array types, whose size
is twice as large as that of regular access types, are not overaligned by
default anymore and therefore don't cause unnecessary padding in record types.
The following program must run quietly on these platforms:
procedure P is
type Array_T is array (Positive range <>) of Integer;
type Access_Array_T is access Array_T;
type Thin_Access_Array_T is access Array_T;
for Thin_Access_Array_T'Size use Standard'Address_Size;
begin
if Access_Array_T'Alignment /= Thin_Access_Array_T'Alignment then
raise Program_Error;
end if;
end;
Tested on x86_64-suse-linux, applied on the mainline.
2012-08-19 Eric Botcazou <ebotcazou@adacore.com>
* layout.adb (Set_Elem_Alignment): Cap the alignment of access types to
that of a regular access type for non-strict-alignment platforms.
* gcc-interface/utils.c (finish_fat_pointer_type): Do not set the
alignment for non-strict-alignment platforms.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 1527 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120819/ccc970ec/attachment.bin>
More information about the Gcc-patches
mailing list