mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: move Used from gc.Node to gc.Name
Node.Used was written to from the backend concurrently with reads of Node.Class for the same ONAME Nodes. I do not know why it was not failing consistently under the race detector, but it is a race. This is likely also a problem with Node.HasVal and Node.HasOpt. They will be handled in a separate CL. Fix Used by moving it to gc.Name and making it a separate bool. There was one non-Name use of Used, marking OLABELs as used. That is no longer needed, now that goto and label checking happens early in the front end. Leave the getters and setters in place, to ease changing the representation in the future (or changing to an interface!). Updates #20144 Change-Id: I9bec7c6d33dcb129a4cfa9d338462ea33087f9f7 Reviewed-on: https://go-review.googlesource.com/42015 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
94d540a4b6
commit
fc08a19cef
15 changed files with 85 additions and 75 deletions
|
|
@ -93,7 +93,6 @@ const (
|
|||
_, nodeNoescape // func arguments do not escape; TODO(rsc): move Noescape to Func struct (see CL 7360)
|
||||
_, nodeBounded // bounds check unnecessary
|
||||
_, nodeAddable // addressable
|
||||
_, nodeUsed // for variable/label declared and not used error
|
||||
_, nodeHasCall // expression contains a function call
|
||||
_, nodeLikely // if statement condition likely
|
||||
_, nodeHasVal // node.E contains a Val
|
||||
|
|
@ -121,7 +120,6 @@ func (n *Node) NonNil() bool { return n.flags&nodeNonNil != 0 }
|
|||
func (n *Node) Noescape() bool { return n.flags&nodeNoescape != 0 }
|
||||
func (n *Node) Bounded() bool { return n.flags&nodeBounded != 0 }
|
||||
func (n *Node) Addable() bool { return n.flags&nodeAddable != 0 }
|
||||
func (n *Node) Used() bool { return n.flags&nodeUsed != 0 }
|
||||
func (n *Node) HasCall() bool { return n.flags&nodeHasCall != 0 }
|
||||
func (n *Node) Likely() bool { return n.flags&nodeLikely != 0 }
|
||||
func (n *Node) HasVal() bool { return n.flags&nodeHasVal != 0 }
|
||||
|
|
@ -148,7 +146,6 @@ func (n *Node) SetNonNil(b bool) { n.flags.set(nodeNonNil, b) }
|
|||
func (n *Node) SetNoescape(b bool) { n.flags.set(nodeNoescape, b) }
|
||||
func (n *Node) SetBounded(b bool) { n.flags.set(nodeBounded, b) }
|
||||
func (n *Node) SetAddable(b bool) { n.flags.set(nodeAddable, b) }
|
||||
func (n *Node) SetUsed(b bool) { n.flags.set(nodeUsed, b) }
|
||||
func (n *Node) SetHasCall(b bool) { n.flags.set(nodeHasCall, b) }
|
||||
func (n *Node) SetLikely(b bool) { n.flags.set(nodeLikely, b) }
|
||||
func (n *Node) SetHasVal(b bool) { n.flags.set(nodeHasVal, b) }
|
||||
|
|
@ -231,6 +228,7 @@ type Name struct {
|
|||
Vargen int32 // unique name for ONAME within a function. Function outputs are numbered starting at one.
|
||||
Funcdepth int32
|
||||
|
||||
used bool // for variable declared and not used error
|
||||
flags bitset8
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +247,7 @@ func (n *Name) Byval() bool { return n.flags&nameByval != 0 }
|
|||
func (n *Name) Needzero() bool { return n.flags&nameNeedzero != 0 }
|
||||
func (n *Name) Keepalive() bool { return n.flags&nameKeepalive != 0 }
|
||||
func (n *Name) AutoTemp() bool { return n.flags&nameAutoTemp != 0 }
|
||||
func (n *Name) Used() bool { return n.used }
|
||||
|
||||
func (n *Name) SetCaptured(b bool) { n.flags.set(nameCaptured, b) }
|
||||
func (n *Name) SetReadonly(b bool) { n.flags.set(nameReadonly, b) }
|
||||
|
|
@ -256,6 +255,7 @@ func (n *Name) SetByval(b bool) { n.flags.set(nameByval, b) }
|
|||
func (n *Name) SetNeedzero(b bool) { n.flags.set(nameNeedzero, b) }
|
||||
func (n *Name) SetKeepalive(b bool) { n.flags.set(nameKeepalive, b) }
|
||||
func (n *Name) SetAutoTemp(b bool) { n.flags.set(nameAutoTemp, b) }
|
||||
func (n *Name) SetUsed(b bool) { n.used = b }
|
||||
|
||||
type Param struct {
|
||||
Ntype *Node
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue