This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] DECL_OFFSET_ALIGN fix
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: [PATCH] DECL_OFFSET_ALIGN fix
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 31 Mar 2000 13:48:12 +0200
- Cc: gcc-patches at gcc dot gnu dot org
Hi!
Below is one possible solution for the DECL_OFFSET_ALIGN issue I've posted
to gcc-bugs today.
As u1.a.off_align is 8 bit, we must either set it to BIGGEST_ALIGNMENT for
larger values (at least in the get_inner_references case it is bounded by
BIGGEST_ALIGNMENT anyway) as done in the patch bellow, or we must enlarge
the types (ie. go for 32bit align and 32bit off_align, which would enlarge
tree for hosts with HOST_BITS_PER_WIDE_INT smaller than 64).
BTW: I think even 24 bit for alignment (in bits) might pose a concern as
well (because that means limitation to 2MB alignment on most machines),
for stuff like:
struct foo { int bar; } __attribute__((aligned(16777216))) a;
but cannot check it now because I'm in the midst of bootstrapping from my
source tree.
2000-03-31 Jakub Jelinek <jakub@redhat.com>
* stor-layout.c (place_field): Set DECL_OFFSET_ALIGN to at most
BIGGEST_ALIGNMENT to allow overflowing. Use the original
offset_align to compute actual_align.
--- gcc/stor-layout.c.jj Thu Mar 30 17:22:29 2000
+++ gcc/stor-layout.c Fri Mar 31 12:51:03 2000
@@ -828,7 +828,7 @@ place_field (rli, field)
normalize_rli (rli);
DECL_FIELD_OFFSET (field) = rli->offset;
DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
- DECL_OFFSET_ALIGN (field) = rli->offset_align;
+ DECL_OFFSET_ALIGN (field) = MIN (rli->offset_align, BIGGEST_ALIGNMENT);
/* If this field ended up more aligned than we thought it would be (we
approximate this by seeing if its position changed), lay out the field
@@ -842,7 +842,7 @@ place_field (rli, field)
* (tree_low_cst (DECL_FIELD_OFFSET (field), 1)
& - tree_low_cst (DECL_FIELD_OFFSET (field), 1)));
else
- actual_align = DECL_OFFSET_ALIGN (field);
+ actual_align = rli->offset_align;
if (known_align != actual_align)
layout_decl (field, actual_align);
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.99-pre2 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________