]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.power64] 6g,8g: remove unnecessary and incorrect reg use scanning
authorAustin Clements <austin@google.com>
Thu, 13 Nov 2014 18:34:20 +0000 (13:34 -0500)
committerAustin Clements <austin@google.com>
Thu, 13 Nov 2014 18:34:20 +0000 (13:34 -0500)
Previously, the 6g and 8g registerizers scanned for used
registers beyond the end of a region being considered for
registerization.  This ancient artifact was copied from the C
compilers, where it was probably necessary to track implicitly
used registers.  In the Go compilers it's harmless (because it
can only over-restrict the set of available registers), but no
longer necessary because the Go compilers correctly track
register use/set information.  The consequences of this extra
scan were (at least) that 1) we would not consider allocating
the AX register if there was a deferproc call in the future
because deferproc uses AX as a return register, so we see the
use of AX, but don't track that AX is set by the CALL, and 2)
we could not consider allocating the DX register if there was
a MUL in the future because MUL implicitly sets DX and (thanks
to an abuse of copyu in this code) we would also consider DX
used.

This commit fixes these problems by nuking this code.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174110043

src/cmd/6g/reg.c
src/cmd/8g/reg.c

index afd3f1056e580589f87100a4d28b7eba8225e5b6..4ce2f4db00177805e29122315712494f6e109112 100644 (file)
@@ -1019,52 +1019,12 @@ paint1(Reg *r, int bn)
        }
 }
 
-uint32
-regset(Reg *r, uint32 bb)
-{
-       uint32 b, set;
-       Adr v;
-       int c;
-
-       set = 0;
-       v = zprog.from;
-       while(b = bb & ~(bb-1)) {
-               v.type = b & 0xFFFF? BtoR(b): BtoF(b);
-               if(v.type == 0)
-                       fatal("zero v.type for %#ux", b);
-               c = copyu(r->f.prog, &v, nil);
-               if(c == 3)
-                       set |= b;
-               bb &= ~b;
-       }
-       return set;
-}
-
-uint32
-reguse(Reg *r, uint32 bb)
-{
-       uint32 b, set;
-       Adr v;
-       int c;
-
-       set = 0;
-       v = zprog.from;
-       while(b = bb & ~(bb-1)) {
-               v.type = b & 0xFFFF? BtoR(b): BtoF(b);
-               c = copyu(r->f.prog, &v, nil);
-               if(c == 1 || c == 2 || c == 4)
-                       set |= b;
-               bb &= ~b;
-       }
-       return set;
-}
-
 uint32
 paint2(Reg *r, int bn)
 {
        Reg *r1;
        int z;
-       uint64 bb, vreg, x;
+       uint64 bb, vreg;
 
        z = bn/64;
        bb = 1LL << (bn%64);
@@ -1108,14 +1068,6 @@ paint2(Reg *r, int bn)
                        break;
        }
 
-       bb = vreg;
-       for(; r; r=(Reg*)r->f.s1) {
-               x = r->regu & ~bb;
-               if(x) {
-                       vreg |= reguse(r, x);
-                       bb |= regset(r, x);
-               }
-       }
        return vreg;
 }
 
index 0fbe684821ad367dd085e83ddceb99adb9ca42f6..79d60bed55205b7c2710f60acf99b8be9213fe30 100644 (file)
@@ -995,50 +995,12 @@ paint1(Reg *r, int bn)
        }
 }
 
-uint32
-regset(Reg *r, uint32 bb)
-{
-       uint32 b, set;
-       Adr v;
-       int c;
-
-       set = 0;
-       v = zprog.from;
-       while(b = bb & ~(bb-1)) {
-               v.type = b & 0xFF ? BtoR(b): BtoF(b);
-               c = copyu(r->f.prog, &v, nil);
-               if(c == 3)
-                       set |= b;
-               bb &= ~b;
-       }
-       return set;
-}
-
-uint32
-reguse(Reg *r, uint32 bb)
-{
-       uint32 b, set;
-       Adr v;
-       int c;
-
-       set = 0;
-       v = zprog.from;
-       while(b = bb & ~(bb-1)) {
-               v.type = b & 0xFF ? BtoR(b): BtoF(b);
-               c = copyu(r->f.prog, &v, nil);
-               if(c == 1 || c == 2 || c == 4)
-                       set |= b;
-               bb &= ~b;
-       }
-       return set;
-}
-
 uint32
 paint2(Reg *r, int bn)
 {
        Reg *r1;
        int z;
-       uint64 bb, vreg, x;
+       uint64 bb, vreg;
 
        z = bn/64;
        bb = 1LL << (bn%64);
@@ -1082,14 +1044,6 @@ paint2(Reg *r, int bn)
                        break;
        }
 
-       bb = vreg;
-       for(; r; r=(Reg*)r->f.s1) {
-               x = r->regu & ~bb;
-               if(x) {
-                       vreg |= reguse(r, x);
-                       bb |= regset(r, x);
-               }
-       }
        return vreg;
 }