diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-01-05 06:43:38 -0800 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-01-05 15:42:33 +0000 |
commit | 77365c5ed739f4882020ff76b2a4f5bfe4e8fc9d (patch) | |
tree | 87e2eb4333d040e79d81241a6d6540b9e4a907aa /src/cmd/compile/internal/escape | |
parent | e09783cbc0a7142719c6210b4eda7b21daad91d5 (diff) | |
download | go-77365c5ed739f4882020ff76b2a4f5bfe4e8fc9d.tar.gz go-77365c5ed739f4882020ff76b2a4f5bfe4e8fc9d.zip |
[dev.regabi] cmd/compile: add Name.Canonical and move Byval
There's a bunch of code that wants to map closure variables back to
their original name, so add a single Name.Canonical method that they
can all use.
Also, move the Byval flag from being stored on individual closure
variables to being stored on the canonical variable.
Passes toolstash -cmp.
Change-Id: Ia3ef81af5a15783d09f04b4e274ce33df94518e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/281541
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/escape')
-rw-r--r-- | src/cmd/compile/internal/escape/escape.go | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/cmd/compile/internal/escape/escape.go b/src/cmd/compile/internal/escape/escape.go index 6a2e685fe8..794c52f5ae 100644 --- a/src/cmd/compile/internal/escape/escape.go +++ b/src/cmd/compile/internal/escape/escape.go @@ -1146,19 +1146,6 @@ func (e *escape) later(k hole) hole { return loc.asHole() } -// canonicalNode returns the canonical *Node that n logically -// represents. -func canonicalNode(n ir.Node) ir.Node { - if n != nil && n.Op() == ir.ONAME && n.Name().IsClosureVar() { - n = n.Name().Defn - if n.Name().IsClosureVar() { - base.Fatalf("still closure var") - } - } - - return n -} - func (e *escape) newLoc(n ir.Node, transient bool) *location { if e.curfn == nil { base.Fatalf("e.curfn isn't set") @@ -1167,7 +1154,9 @@ func (e *escape) newLoc(n ir.Node, transient bool) *location { base.ErrorfAt(n.Pos(), "%v is incomplete (or unallocatable); stack allocation disallowed", n.Type()) } - n = canonicalNode(n) + if n != nil && n.Op() == ir.ONAME { + n = n.(*ir.Name).Canonical() + } loc := &location{ n: n, curfn: e.curfn, @@ -1196,8 +1185,7 @@ func (e *escape) newLoc(n ir.Node, transient bool) *location { } func (b *batch) oldLoc(n *ir.Name) *location { - n = canonicalNode(n).(*ir.Name) - return n.Opt.(*location) + return n.Canonical().Opt.(*location) } func (l *location) asHole() hole { |