------- Additional Comments From dje at gcc dot gnu dot org 2005-07-27 22:03 ------- The testcase passes three structs with three members each for a total of nine words. AIX, Darwin, and PPC64 Linux pass structs by value in GPRs r3-r10 allowing a maximum of 8 words. The ninth argument is passed on the stack. This bug appears to be a problem with either argument passing or scheduling.
struct S a = { 3, 4, 5 }, b = { 6, 7, 8 }, c = { 9, 10, 11 }; main() calls baz3 (c, a, b) and the arguments are correct 9, 10, 11, 3, 4, 5, 6, 7 in GPRs and 8 on stack at 56(r1) baz3 (struct S x, struct S y, struct S z) { return foo3 (y, z, x); } is compiled as: addi r2,r1,24 addi r11,r1,36 stswi r3,r2,12 <== store baz3 argument x to r1+24,28,32 addi r2,r1,48 <== address of foo3 second argument stswi r6,r11,12 lwz r0,32(r1) <== load x.c stw r9,48(r1) mr r9,r3 stw r10,52(r1) stw r0,56(r1) <== store x.c to third argument last member on stack lwz r10,28(r1) lswi r3,r11,12 lswi r6,r2,12 <== load foo3 second argument from r2+48,52,56 b _foo3 GCC stores the argument passed on the stack for foo3 before loading the second argument from the same location. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23090