DImode is aligned at 4 byte according to i386 psABI. This 4.4 patch http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00184.html will use 4byte alignment for DImode. But Ada doesn't follow i386 psABI. validate_alignment in ada/decl.c does new_align = UI_To_Int (alignment); ... align = MAX (align, new_align == 0 ? 1 : new_align * BITS_PER_UNIT); It changes DImode alignment from 32bit to 64bit and turns DImode integer into a DImode record. As the result, Ada fails to compile s-pack33.adb: s-pack33.adb:52:49: size for "E0" too small, minimum allowed is 64 s-pack33.adb:53:49: size for "E1" too small, minimum allowed is 64 s-pack33.adb:54:49: size for "E2" too small, minimum allowed is 64 s-pack33.adb:55:49: size for "E3" too small, minimum allowed is 64 s-pack33.adb:56:49: size for "E4" too small, minimum allowed is 64 s-pack33.adb:57:49: size for "E5" too small, minimum allowed is 64 s-pack33.adb:58:49: size for "E6" too small, minimum allowed is 64 s-pack33.adb:59:49: size for "E7" too small, minimum allowed is 64 s-pack33.adb:62:30: size for "Cluster" too small, minimum allowed is 512 because validate_size has (gdb) call debug_tree (size) <integer_cst 0xb7d0d4d0 type <integer_type 0xb7cf8068 bit_size_type> constant invariant 33> (gdb) call debug_tree (type_size) <integer_cst 0xb7ceb738 type <integer_type 0xb7cf8068 bit_size_type> constant invariant visited 64> (gdb) call debug_tree (gnu_type) <record_type 0xb7d0ed00 system__pack_33__bits_33___PAD sizes-gimplified asm_written visited type_5 DI size <integer_cst 0xb7ceb738 type <integer_type 0xb7cf8068 bit_size_type> constant invariant visited 64> unit size <integer_cst 0xb7ceb754 type <integer_type 0xb7cf8000 long int> constant invariant visited 8> align 64 symtab -1210166256 alias set -1 canonical type 0xb7d0ed00 fields <field_decl 0xb7d052e0 F type <integer_type 0xb7d0ec98 system__pack_33__bits_33 type <integer_type 0xb7d0ec30 system__pack_33__bits_33___UMT> sizes-gimplified asm_written visited unsigned type_2 DI size <integer_cst 0xb7ceb738 64> unit size <integer_cst 0xb7ceb754 8> align 32 symtab -1210166464 alias set -1 canonical type 0xb7d0ec98 precision 64 min <integer_cst 0xb7d0d364 0> max <integer_cst 0xb7d0d3f0 0x1ffffffff>> unsigned decl_3 decl_5 DI file s-pack33.ads line 6 col 9 size <integer_cst 0xb7ceb738 64> unit size <integer_cst 0xb7ceb754 8> align 32 offset_align 128 offset <integer_cst 0xb7ceb968 constant invariant visited 0> bit offset <integer_cst 0xb7ceb984 constant invariant 0> context <record_type 0xb7d0ed00 system__pack_33__bits_33___PAD>> Ada size <integer_cst 0xb7ceb738 64> chain <type_decl 0xb7d0edd0 system__pack_33__bits_33___PAD>> (gdb) Before my patch, validate_size has (gdb) call debug_tree (size) <integer_cst 0xb7c9f444 type <integer_type 0xb7c8a068 bit_size_type> constant invariant 33> (gdb) <integer_cst 0xb7c9f444 type <integer_type 0xb7c8a068 bit_size_type> constant invariant 33> (gdb) call debug_tree (type_size) <integer_cst 0xb7c9f444 type <integer_type 0xb7c8a068 bit_size_type> constant invariant 33> (gdb) call debug_tree (gnu_type) <integer_type 0xb7ca0c98 system__pack_33__bits_33 type <integer_type 0xb7ca0c30 system__pack_33__bits_33___UMT public unsigned type_1 DI size <integer_cst 0xb7c7d738 constant invariant visited 64> unit size <integer_cst 0xb7c7d754 constant invariant visited 8> align 64 symtab -1208441944 alias set -1 canonical type 0xb7ca0c30 precision 64 min <integer_cst 0xb7c9f364 0> max <integer_cst 0xb7c9894c -1> modulus <integer_cst 0xb7c9f3d4 constant invariant 0x200000000>> sizes-gimplified visited unsigned type_2 DI size <integer_cst 0xb7c7d738 64> unit size <integer_cst 0xb7c7d754 8> align 64 symtab -1208442048 alias set -1 canonical type 0xb7ca0c98 precision 64 min <integer_cst 0xb7c9f364 0> max <integer_cst 0xb7c9f3f0 0x1ffffffff> RM size <integer_cst 0xb7c9f444 type <integer_type 0xb7c8a068 bit_size_type> constant invariant 33>> (gdb)
psABI is only for C last time I remembered.
maybe_pad_type has if (align == TYPE_ALIGN (type)) align = 0; if (align == 0 && !size) return type; ... record = make_node (RECORD_TYPE); That is Ada expects 8 byte alignment for DImode. But TYPE_ALIGN (type), which conforms to psABI, is 4 byte for DImode.
Ada should either define its own alignment, independent of psABI, or it should just follow psABI for alignment.
Thanks for opening the PR However: > DImode is aligned at 4 byte according to i386 psABI. Of course the psABI doesn't say anything about DImode, only about long long. DImode is an internal concept of the GCC compiler. > But Ada doesn't follow i386 psABI. Ada doesn't have to abide by the psABI, except when it interfaces C.
I'll look into this once 4.3.0 is released.
Subject: Bug 35186 Author: hjl Date: Tue Feb 19 14:35:48 2008 New Revision: 132433 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132433 Log: 2008-02-19 H.J. Lu <hongjiu.lu@intel.com> PR Ada/35186 * config/i386/i386-modes.def: Revert the last DI alignment change until Ada people can look into it. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386-modes.def
Subject: Bug 35186 Author: ebotcazou Date: Thu Mar 6 00:44:11 2008 New Revision: 132963 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132963 Log: PR ada/35186 * decl.c (maybe_pad_type): Avoid padding an integral type when bumping its alignment is sufficient. Added: trunk/gcc/testsuite/gnat.dg/specs/pack33.ads Modified: trunk/gcc/ada/ChangeLog trunk/gcc/ada/decl.c trunk/gcc/testsuite/ChangeLog
This should be OK now.
Subject: Bug 35186 Author: ebotcazou Date: Tue Mar 25 17:58:54 2008 New Revision: 133526 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133526 Log: Revert 2008-03-05 Eric Botcazou <ebotcazou@adacore.com> PR ada/35186 * decl.c (maybe_pad_type): Avoid padding an integral type when bumping its alignment is sufficient. Modified: trunk/gcc/ada/ChangeLog trunk/gcc/ada/decl.c