This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH [mainline] - Fix passing of zero-sized structs in apple-ppc-darwin mixed mode
On Mon, Jun 28, 2004 at 02:38:40PM -0700, Fariborz Jahanian wrote:
> mygccm5 -mcpu=G5 struct-by-value-2_x.c -c
> struct-by-value-2_x.c: In function `test2_uc0':
> struct-by-value-2_x.c:109: internal compiler error: in assign_parms, at
> function.c:4825
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
These are all zero length array problems. (And I reckon your patch in
http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01972.html introduces the
same regressions..)
Two fixes spring to mind. One is to return a NULL_RTX for zero size
objects. The other is to make an obvious fix to assign_parms. I favour
an assign_parms fix because returning a NULL_RTX from function_arg
results in the wrong stack home for zero size params. Whether this
matters or not is rather academic, since you can't do much with a zero
size param. Still, we ought to get it right. Maybe I'd better explain
with some code examples (taken from struct-by-value-2_y.c):
struct Suc0 { unsigned char i[0]; };
extern void checkuc0 (struct Suc0 *);
void testuc0 (struct Suc0 s1)
{
checkuc0 (&s1);
}
What's the address of s1? Well, if function_arg returns a NULL, then s1
is assumed to be passed on the stack. This results in an address just
past the register parameter save area, or sp + 24 + 32 for darwin. If
function_arg returns r3, then the address is the stack home for r3, or
sp + 24. I reckon that's the right place.
So, here's the assign_parms fix. I claim it's an obvious patch, since
the PARM_BOUNDARY check is ensuring that register parms can be moved
to/from the corresponding stack parm. With size zero, we never move
anything.
* function.c (assign_parms): Don't abort with zero size stack
parm failing the PARM_BOUNDARY check.
Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.529
diff -u -p -r1.529 function.c
--- gcc/function.c 22 Jun 2004 23:54:46 -0000 1.529
+++ gcc/function.c 29 Jun 2004 03:26:06 -0000
@@ -4821,7 +4821,7 @@ assign_parms (tree fndecl)
}
else if (GET_CODE (entry_parm) == PARALLEL)
;
- else if (PARM_BOUNDARY % BITS_PER_WORD != 0)
+ else if (size != 0 && PARM_BOUNDARY % BITS_PER_WORD != 0)
abort ();
mem = validize_mem (stack_parm);
--
Alan Modra
IBM OzLabs - Linux Technology Centre