This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

allow for small DECL_OFFSET_ALIGN.



DECL_OFFSET_ALIGN is only 8 bits wide in the tree structure.  This is
unfortunate if you want a field aligned to a 256-bit boundary.

In fact, it is fatal because the alignment becomes zero and then if
STRICT_ALIGNMENT is set and the middle-end tries to copy the field, it
will copy it in chunks of 0 bits, generating an infinite amount of
RTL.  This happens on aix64, and the effect is that the machine
runs out of swap, and then thrashes until someone manages to log in
(which happens very slowly) and kill the process.

This patch fixes it by storing the alignment as a log, so the field
can hold up to 2^255-bit alignment, which is much better.  I didn't
increase the field size because apparently this structure is a large
proportion of GCC's memory consumption.

Note that there seems to be other problems with the code that does
this.  It seems to be confused about whether BIGGEST_ALIGNMENT
is the maximum value of this field (it is not, and should not be).

OK to commit?

Tested with bootstrap on rs6000-ibm-aix4.3.3.0 and tested on
powerpc-eabisim.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

===File ~/cygnus/patches/rs6000-64bugs-8align.patch=========
2000-05-13  Geoffrey Keating  <geoffk@cygnus.com>

	* tree.h (DECL_OFFSET_ALIGN): Make the off_align field of
	the tree structure an exponent rather than an explicit alignment
	so it doesn't overflow.
	(SET_DECL_OFFSET_ALIGN): New macro.
	* stor-layout.c (place_union_field): Use SET_DECL_OFFSET_ALIGN
	rather than DECL_OFFSET_ALIGN.
	(place_field): Likewise.

Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stor-layout.c,v
retrieving revision 1.71
diff -c -p -r1.71 stor-layout.c
*** stor-layout.c	2000/05/04 21:15:03	1.71
--- stor-layout.c	2000/05/13 19:57:55
*************** place_union_field (rli, field)
*** 576,582 ****
    
    DECL_FIELD_OFFSET (field) = size_zero_node;
    DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node;
!   DECL_OFFSET_ALIGN (field) = BIGGEST_ALIGNMENT;
  
    /* Union must be at least as aligned as any field requires.  */
    rli->record_align = MAX (rli->record_align, DECL_ALIGN (field));
--- 576,582 ----
    
    DECL_FIELD_OFFSET (field) = size_zero_node;
    DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node;
!   SET_DECL_OFFSET_ALIGN (field, BIGGEST_ALIGNMENT);
  
    /* Union must be at least as aligned as any field requires.  */
    rli->record_align = MAX (rli->record_align, DECL_ALIGN (field));
*************** place_field (rli, field)
*** 832,838 ****
    normalize_rli (rli);
    DECL_FIELD_OFFSET (field) = rli->offset;
    DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
!   DECL_OFFSET_ALIGN (field) = rli->offset_align;
  
    /* 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
--- 832,838 ----
    normalize_rli (rli);
    DECL_FIELD_OFFSET (field) = rli->offset;
    DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
!   SET_DECL_OFFSET_ALIGN (field, rli->offset_align);
  
    /* 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
Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.168
diff -c -p -r1.168 tree.h
*** tree.h	2000/05/04 21:15:04	1.168
--- tree.h	2000/05/13 19:57:55
*************** struct tree_type
*** 1281,1288 ****
  #define DECL_SIZE_UNIT(NODE) (DECL_CHECK (NODE)->decl.size_unit)
  /* Holds the alignment required for the datum.  */
  #define DECL_ALIGN(NODE) (DECL_CHECK (NODE)->decl.u1.a.align)
! /* For FIELD_DECLs, holds the alignment that DECL_FIELD_OFFSET has.  */
! #define DECL_OFFSET_ALIGN(NODE) (FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align)
  /* Holds the machine mode corresponding to the declaration of a variable or
     field.  Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
     FIELD_DECL.  */
--- 1281,1295 ----
  #define DECL_SIZE_UNIT(NODE) (DECL_CHECK (NODE)->decl.size_unit)
  /* Holds the alignment required for the datum.  */
  #define DECL_ALIGN(NODE) (DECL_CHECK (NODE)->decl.u1.a.align)
! /* For FIELD_DECLs, off_align holds the number of low-order bits of
!    DECL_FIELD_OFFSET which are known to be always zero.
!    DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
!    has.  */
! #define DECL_OFFSET_ALIGN(NODE) \
!   (1UL << FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align)
! /* Specify that DECL_ALIGN(NODE) is a multiple of X.  */
! #define SET_DECL_OFFSET_ALIGN(NODE, X) \
!   (FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align = ffs (X))
  /* Holds the machine mode corresponding to the declaration of a variable or
     field.  Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
     FIELD_DECL.  */
============================================================

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]