From: Matthew Dempsky Date: Wed, 25 Nov 2020 22:02:46 +0000 (-0800) Subject: [dev.regabi] cmd/compile: fix latent import/export issue with break/continue X-Git-Tag: go1.17beta1~1539^2~438 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=88e33f6ecb;p=gostls13.git [dev.regabi] cmd/compile: fix latent import/export issue with break/continue In CL 145200, I changed OBREAK, OCONTINUE, OGOTO, and OLABEL to just use Sym instead of Node. However, within the export data, I forgot to update the code for OBREAK and OCONTINUE. This isn't currently an issue because the inliner currently disallows these anyway, but it'll be an issue in the future once we add support for inlining them. Also, Russ independently ran into it in CL 273246. Updates #14768. Change-Id: I94575df59c08a750b0dce1d3ce612aba7bfeeb76 Reviewed-on: https://go-review.googlesource.com/c/go/+/273270 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Trust: Matthew Dempsky Reviewed-by: Russ Cox --- diff --git a/src/cmd/compile/internal/gc/iexport.go b/src/cmd/compile/internal/gc/iexport.go index ef52e40f21..7c42e43bee 100644 --- a/src/cmd/compile/internal/gc/iexport.go +++ b/src/cmd/compile/internal/gc/iexport.go @@ -1146,18 +1146,17 @@ func (w *exportWriter) stmt(n ir.Node) { w.op(ir.OFALL) w.pos(n.Pos()) - case ir.OBREAK, ir.OCONTINUE: - w.op(op) - w.pos(n.Pos()) - w.exprsOrNil(n.Left(), nil) - case ir.OEMPTY: // nothing to emit - case ir.OGOTO, ir.OLABEL: + case ir.OBREAK, ir.OCONTINUE, ir.OGOTO, ir.OLABEL: w.op(op) w.pos(n.Pos()) - w.string(n.Sym().Name) + label := "" + if sym := n.Sym(); sym != nil { + label = sym.Name + } + w.string(label) default: base.Fatalf("exporter: CANNOT EXPORT: %v\nPlease notify gri@\n", n.Op()) diff --git a/src/cmd/compile/internal/gc/iimport.go b/src/cmd/compile/internal/gc/iimport.go index 77078c118a..066d956b93 100644 --- a/src/cmd/compile/internal/gc/iimport.go +++ b/src/cmd/compile/internal/gc/iimport.go @@ -1052,20 +1052,14 @@ func (r *importReader) node() ir.Node { n := ir.NodAt(r.pos(), ir.OFALL, nil, nil) return n - case ir.OBREAK, ir.OCONTINUE: - pos := r.pos() - left, _ := r.exprsOrNil() - if left != nil { - left = NewName(left.Sym()) - } - return ir.NodAt(pos, op, left, nil) - // case OEMPTY: // unreachable - not emitted by exporter - case ir.OGOTO, ir.OLABEL: + case ir.OBREAK, ir.OCONTINUE, ir.OGOTO, ir.OLABEL: n := ir.NodAt(r.pos(), op, nil, nil) - n.SetSym(lookup(r.string())) + if label := r.string(); label != "" { + n.SetSym(lookup(label)) + } return n case ir.OEND: