Skip to content

Commit

Permalink
[dev.regabi] cmd/compile: fix latent import/export issue with break/c…
Browse files Browse the repository at this point in the history
…ontinue

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 <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Trust: Matthew Dempsky <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
mdempsky committed Nov 25, 2020
1 parent 40f5bc4 commit 88e33f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
13 changes: 6 additions & 7 deletions src/cmd/compile/internal/gc/iexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
14 changes: 4 additions & 10 deletions src/cmd/compile/internal/gc/iimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 88e33f6

Please sign in to comment.