]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6g: nacl: zero odd multiple of widthptr correctly
authorKeith Randall <khr@golang.org>
Thu, 10 Apr 2014 14:59:46 +0000 (07:59 -0700)
committerKeith Randall <khr@golang.org>
Thu, 10 Apr 2014 14:59:46 +0000 (07:59 -0700)
LGTM=iant
R=remyoudompheng, iant
CC=golang-codereviews
https://golang.org/cl/86270043

src/cmd/6g/ggen.c

index 991783bc578494dea08bc7198e369937c1a4ef4a..3d27fb2ab9d137d946639fbe480bb7925b9262a9 100644 (file)
@@ -73,6 +73,14 @@ zerorange(Prog *p, vlong frame, vlong lo, vlong hi, uint32 *ax)
                p = appendpp(p, AMOVQ, D_CONST, 0, D_AX, 0);
                *ax = 1;
        }
+       if(cnt % widthreg != 0) {
+               // should only happen with nacl
+               if(cnt % widthptr != 0)
+                       fatal("zerorange count not a multiple of widthptr %d", cnt);
+               p = appendpp(p, AMOVL, D_AX, 0, D_SP+D_INDIR, frame+lo);
+               lo += widthptr;
+               cnt -= widthptr;
+       }
        if(cnt <= 4*widthreg) {
                for(i = 0; i < cnt; i += widthreg) {
                        p = appendpp(p, AMOVQ, D_AX, 0, D_SP+D_INDIR, frame+lo+i);