Commit ecc6a816 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: prevent modification of ONAME/OLITERAL/OTYPES nodes in walkexpr

ONAME, OLITERAL, and OTYPE nodes can be shared between functions.
In a concurrent backend, such nodes might be walked concurrently
with being read in other functions.
Arrange for them to be unmodified by walk.

This is a follow-up to CL 38609.

Passes toolstash-check.

Updates #15756

Change-Id: I03ff1d2c0ad81dafac3fd55caa218939cf7c0565
Reviewed-on: https://go-review.googlesource.com/38655
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent ef1ab0f0
...@@ -1181,7 +1181,11 @@ func updateHasCall(n *Node) { ...@@ -1181,7 +1181,11 @@ func updateHasCall(n *Node) {
} }
switch n.Op { switch n.Op {
case OLITERAL, ONAME: case OLITERAL, ONAME, OTYPE:
if b || n.HasCall() {
Fatalf("OLITERAL/ONAME/OTYPE should never have calls: %+v", n)
}
return
case OAS: case OAS:
if needwritebarrier(n.Left) { if needwritebarrier(n.Left) {
b = true b = true
......
...@@ -498,7 +498,10 @@ opswitch: ...@@ -498,7 +498,10 @@ opswitch:
Dump("walk", n) Dump("walk", n)
Fatalf("walkexpr: switch 1 unknown op %+S", n) Fatalf("walkexpr: switch 1 unknown op %+S", n)
case OTYPE, ONONAME, OINDREGSP, OEMPTY, OGETG: case ONONAME, OINDREGSP, OEMPTY, OGETG:
case OTYPE, ONAME, OLITERAL:
// TODO(mdempsky): Just return n; see discussion on CL 38655.
case ONOT, OMINUS, OPLUS, OCOM, OREAL, OIMAG, ODOTMETH, ODOTINTER, case ONOT, OMINUS, OPLUS, OCOM, OREAL, OIMAG, ODOTMETH, ODOTINTER,
OIND, OSPTR, OITAB, OIDATA, ODOTTYPE, ODOTTYPE2, OADDR: OIND, OSPTR, OITAB, OIDATA, ODOTTYPE, ODOTTYPE2, OADDR:
...@@ -593,7 +596,7 @@ opswitch: ...@@ -593,7 +596,7 @@ opswitch:
case ORECOVER: case ORECOVER:
n = mkcall("gorecover", n.Type, init, nod(OADDR, nodfp, nil)) n = mkcall("gorecover", n.Type, init, nod(OADDR, nodfp, nil))
case OLITERAL, OCLOSUREVAR, OCFUNC, ONAME: case OCLOSUREVAR, OCFUNC:
n.SetAddable(true) n.SetAddable(true)
case OCALLINTER: case OCALLINTER:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment