From c6de5d8d1f56465869a9271753796da35c60f3e6 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 30 Nov 2020 13:50:05 -0800 Subject: [PATCH] [dev.regabi] cmd/compile: simplify export data representation of nil 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 Run-TryBot: Matthew Dempsky Reviewed-by: Russ Cox TryBot-Result: Go Bot --- src/cmd/compile/internal/gc/iexport.go | 6 +----- src/cmd/compile/internal/gc/iimport.go | 17 ++++++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/cmd/compile/internal/gc/iexport.go b/src/cmd/compile/internal/gc/iexport.go index c9f5d0c85c..f19acb8bc2 100644 --- a/src/cmd/compile/internal/gc/iexport.go +++ b/src/cmd/compile/internal/gc/iexport.go @@ -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()) diff --git a/src/cmd/compile/internal/gc/iimport.go b/src/cmd/compile/internal/gc/iimport.go index c219b70e0f..57c5e62182 100644 --- a/src/cmd/compile/internal/gc/iimport.go +++ b/src/cmd/compile/internal/gc/iimport.go @@ -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 -- 2.48.1