This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Build problems on Solaris 2.5.1
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: Build problems on Solaris 2.5.1
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Fri, 10 Nov 2000 15:35:57 +0000
- Cc: gcc-bugs at gcc dot gnu dot org
- Cc: rearnsha at arm dot com
- Organization: ARM Ltd.
- Reply-To: rearnsha at arm dot com
> The problem is decode_rtx_const, which tries to memset its VALUE argument.
> However, this has just been xmalloced (in record_constant_rtx) with
>
>
> ptr = ((struct constant_descriptor *)
> xcalloc (1,
> (sizeof (struct constant_descriptor)
> + sizeof (struct rtx_const) - 1)));
> decode_rtx_const (mode, x, (struct rtx_const *) ptr->contents);
>
> Now the native compiler is optimizing the memset into two "std"
> instructions. Unfortunately, the pointer is only word aligned, not dword
> aligned, so the std instruction is generating a bus error.
>
> Now it looks to me that the code in record_constant_rtx is doing the dodgy
> thing (since after all, it is messing around with casts), but I could be
> wrong. Is it reasonable to expect struct rtx_const to be dword aligned on
> a sparc?
>
Here's a patch
<date> Richard Earnshaw (rearnsha@arm.com>
* varasm.c (struct constant_descriptor): Put CONTENTS inside a
union to make it well-aligned. Update all uses.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.137
diff -p -r1.137 varasm.c
*** varasm.c 2000/11/03 18:55:53 1.137
--- varasm.c 2000/11/10 15:20:55
*************** struct constant_descriptor
*** 2327,2333 ****
struct constant_descriptor *next;
char *label;
rtx rtl;
! unsigned char contents[1];
};
#define HASHBITS 30
--- 2327,2337 ----
struct constant_descriptor *next;
char *label;
rtx rtl;
! union
! {
! unsigned char contents[1];
! double algn; /* Make sure this is well aligned. */
! } u;
};
#define HASHBITS 30
*************** compare_constant (exp, desc)
*** 2477,2483 ****
tree exp;
struct constant_descriptor *desc;
{
! return 0 != compare_constant_1 (exp, desc->contents);
}
/* Compare constant expression EXP with a substring P of a constant descriptor.
--- 2481,2487 ----
tree exp;
struct constant_descriptor *desc;
{
! return 0 != compare_constant_1 (exp, desc->u.contents);
}
/* Compare constant expression EXP with a substring P of a constant descriptor.
*************** compare_constant_rtx (mode, x, desc)
*** 3475,3481 ****
rtx x;
struct constant_descriptor *desc;
{
! register int *p = (int *) desc->contents;
register int *strp;
register int len;
struct rtx_const value;
--- 3479,3485 ----
rtx x;
struct constant_descriptor *desc;
{
! register int *p = (int *) desc->u.contents;
register int *strp;
register int len;
struct rtx_const value;
*************** record_constant_rtx (mode, x)
*** 3505,3512 ****
ptr = ((struct constant_descriptor *)
xcalloc (1,
(sizeof (struct constant_descriptor)
! + sizeof (struct rtx_const) - 1)));
! decode_rtx_const (mode, x, (struct rtx_const *) ptr->contents);
return ptr;
}
--- 3509,3516 ----
ptr = ((struct constant_descriptor *)
xcalloc (1,
(sizeof (struct constant_descriptor)
! + sizeof (struct rtx_const) - sizeof (double))));
! decode_rtx_const (mode, x, (struct rtx_const *) ptr->u.contents);
return ptr;
}