]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove unused cases in Naddr
authorMatthew Dempsky <mdempsky@google.com>
Fri, 16 Sep 2016 02:48:53 +0000 (19:48 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 16 Sep 2016 03:45:18 +0000 (03:45 +0000)
Gins, and in turn Naddr, is only used with ONAME and OLITERAL Nodes,
so we can drastically simplify Naddr.

Passes toolstash/buildall.

Change-Id: I2deb7eb771fd55e7c7f00040a9aee54588fcac11
Reviewed-on: https://go-review.googlesource.com/29247
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/gsubr.go

index 201698e7001812bcec749aabdb76e9fd55a0e16e..1be8788dfca81d8a6e0ab99d78a6e88b99c72fea 100644 (file)
@@ -237,16 +237,6 @@ func Naddr(a *obj.Addr, n *Node) {
                return
        }
 
-       if n.Type != nil && n.Type.Etype != TIDEAL {
-               // TODO(rsc): This is undone by the selective clearing of width below,
-               // to match architectures that were not as aggressive in setting width
-               // during naddr. Those widths must be cleared to avoid triggering
-               // failures in gins when it detects real but heretofore latent (and one
-               // hopes innocuous) type mismatches.
-               // The type mismatches should be fixed and the clearing below removed.
-               dowidth(n.Type)
-       }
-
        switch n.Op {
        default:
                a := a // copy to let escape into Ctxt.Dconv
@@ -254,33 +244,6 @@ func Naddr(a *obj.Addr, n *Node) {
                Dump("naddr", n)
                Fatalf("naddr: bad %v %v", n.Op, Ctxt.Dconv(a))
 
-       case OREGISTER:
-               a.Type = obj.TYPE_REG
-               a.Reg = n.Reg
-               a.Sym = nil
-
-       case OINDREG:
-               a.Type = obj.TYPE_MEM
-               a.Reg = n.Reg
-               a.Sym = Linksym(n.Sym)
-               a.Offset = n.Xoffset
-               if a.Offset != int64(int32(a.Offset)) {
-                       yyerror("offset %d too large for OINDREG", a.Offset)
-               }
-
-       case OCLOSUREVAR:
-               if !Curfn.Func.Needctxt {
-                       Fatalf("closurevar without needctxt")
-               }
-               a.Type = obj.TYPE_MEM
-               a.Reg = int16(Thearch.REGCTXT)
-               a.Sym = nil
-               a.Offset = n.Xoffset
-
-       case OCFUNC:
-               Naddr(a, n.Left)
-               a.Sym = Linksym(n.Left.Sym)
-
        case ONAME:
                a.Offset = n.Xoffset
                s := n.Sym
@@ -317,17 +280,6 @@ func Naddr(a *obj.Addr, n *Node) {
 
                a.Sym = Linksym(s)
 
-       case ODOT:
-               // A special case to make write barriers more efficient.
-               // Taking the address of the first field of a named struct
-               // is the same as taking the address of the struct.
-               if !n.Left.Type.IsStruct() || n.Left.Type.Field(0).Sym != n.Sym {
-                       Debug['h'] = 1
-                       Dump("naddr", n)
-                       Fatalf("naddr: bad %v %v", n.Op, Ctxt.Dconv(a))
-               }
-               Naddr(a, n.Left)
-
        case OLITERAL:
                switch u := n.Val().U.(type) {
                default:
@@ -355,56 +307,6 @@ func Naddr(a *obj.Addr, n *Node) {
                        a.Type = obj.TYPE_CONST
                        a.Offset = 0
                }
-
-       case OADDR:
-               Naddr(a, n.Left)
-               if a.Type != obj.TYPE_MEM {
-                       a := a // copy to let escape into Ctxt.Dconv
-                       Fatalf("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), n.Left.Op)
-               }
-               a.Type = obj.TYPE_ADDR
-
-       case OITAB:
-               // itable of interface value
-               Naddr(a, n.Left)
-               if a.Type == obj.TYPE_CONST && a.Offset == 0 {
-                       break // itab(nil)
-               }
-
-       case OIDATA:
-               // idata of interface value
-               Naddr(a, n.Left)
-               if a.Type == obj.TYPE_CONST && a.Offset == 0 {
-                       break // idata(nil)
-               }
-               a.Offset += int64(Widthptr)
-
-               // pointer in a string or slice
-       case OSPTR:
-               Naddr(a, n.Left)
-
-               if a.Type == obj.TYPE_CONST && a.Offset == 0 {
-                       break // ptr(nil)
-               }
-               a.Offset += int64(array_array)
-
-               // len of string or slice
-       case OLEN:
-               Naddr(a, n.Left)
-
-               if a.Type == obj.TYPE_CONST && a.Offset == 0 {
-                       break // len(nil)
-               }
-               a.Offset += int64(array_nel)
-
-               // cap of string or slice
-       case OCAP:
-               Naddr(a, n.Left)
-
-               if a.Type == obj.TYPE_CONST && a.Offset == 0 {
-                       break // cap(nil)
-               }
-               a.Offset += int64(array_cap)
        }
 }