]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: simplify export data representation of nil
authorMatthew Dempsky <mdempsky@google.com>
Mon, 30 Nov 2020 21:50:05 +0000 (13:50 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 30 Nov 2020 22:10:39 +0000 (22:10 +0000)
The handling of ONIL and Orig has been a mess for a while, and dates
back to how fmt.go used to print out typed nils. That hasn't applied
for a while, but we've kept dragging it along to appease toolstash
with the intention of someday finally removing it.

Today is that day.

Change-Id: I9a441628e53068ab1993cd2b67b977574d8117b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/274212
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/iimport.go

index c9f5d0c85c401f1fd88482962f1fca417b8bc654..f19acb8bc25233b580f80db3550622071ca6444f 100644 (file)
@@ -1201,11 +1201,7 @@ func (w *exportWriter) expr(n ir.Node) {
                if !n.Type().HasNil() {
                        base.Fatalf("unexpected type for nil: %v", n.Type())
                }
-               if orig := ir.Orig(n); orig != nil && orig != n {
-                       w.expr(orig)
-                       break
-               }
-               w.op(ir.OLITERAL)
+               w.op(ir.ONIL)
                w.pos(n.Pos())
                w.typ(n.Type())
 
index c219b70e0fc4b23cd083e039e4df5ae19977e35f..57c5e621829c8de20748a7c35627fee6160f637d 100644 (file)
@@ -809,20 +809,19 @@ func (r *importReader) node() ir.Node {
        // case OPAREN:
        //      unreachable - unpacked by exporter
 
-       // case ONIL:
-       //      unreachable - mapped to OLITERAL
+       case ir.ONIL:
+               pos := r.pos()
+               typ := r.typ()
+
+               n := npos(pos, nodnil())
+               n.SetType(typ)
+               return n
 
        case ir.OLITERAL:
                pos := r.pos()
                typ := r.typ()
 
-               var n ir.Node
-               if typ.HasNil() {
-                       n = nodnil()
-               } else {
-                       n = ir.NewLiteral(r.value(typ))
-               }
-               n = npos(pos, n)
+               n := npos(pos, ir.NewLiteral(r.value(typ)))
                n.SetType(typ)
                return n