From f61639d4e2657267b25fe6e867048f8bdd14f7ae Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 2 Feb 2009 13:41:38 -0800 Subject: [PATCH] 6g return struct fix: make t->width of funarg struct be width of struct. emit MOVSL for 4-byte copy. R=ken OCL=24108 CL=24111 --- src/cmd/6g/align.c | 7 ++++++- src/cmd/6g/cgen.c | 8 +++----- src/cmd/6g/gsubr.c | 4 +--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cmd/6g/align.c b/src/cmd/6g/align.c index 5d55e2ca912..a2a8e2808bd 100644 --- a/src/cmd/6g/align.c +++ b/src/cmd/6g/align.c @@ -68,7 +68,12 @@ widstruct(Type *t, uint32 o, int flag) // final width is rounded if(flag) o = rnd(o, maxround); - t->width = o; + + // type width only includes back to first field's offset + if(t->type == T) + t->width = 0; + else + t->width = o - t->type->width; return o; } diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c index 4a7404e8ca8..05dd256ffad 100644 --- a/src/cmd/6g/cgen.c +++ b/src/cmd/6g/cgen.c @@ -906,11 +906,9 @@ sgen(Node *n, Node *ns, int32 w) } if(c >= 4) { - gconreg(AMOVQ, c, D_CX); - gins(AREP, N, N); // repeat - gins(AMOVSB, N, N); // MOVB *(SI)+,*(DI)+ - - } else + gins(AMOVSL, N, N); // MOVL *(SI)+,*(DI)+ + c -= 4; + } while(c > 0) { gins(AMOVSB, N, N); // MOVB *(SI)+,*(DI)+ c--; diff --git a/src/cmd/6g/gsubr.c b/src/cmd/6g/gsubr.c index 67def995271..4d091da648d 100644 --- a/src/cmd/6g/gsubr.c +++ b/src/cmd/6g/gsubr.c @@ -1887,11 +1887,9 @@ lsort(Sig *l, int(*f)(Sig*, Sig*)) void setmaxarg(Type *t) { - Type *to; int32 w; - to = *getoutarg(t); - w = to->width; + w = t->argwid; if(w > maxarg) maxarg = w; }