aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/logopt
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-11-28 15:28:18 -0500
committerRuss Cox <rsc@golang.org>2020-11-30 23:48:13 +0000
commit7c9b6b1ca249c14d358075da9678cd1c20041b21 (patch)
tree26ca18599791bc1a1f073cf551c1bf627dbcdc60 /src/cmd/compile/internal/logopt
parentc6de5d8d1f56465869a9271753796da35c60f3e6 (diff)
downloadgo-7c9b6b1ca249c14d358075da9678cd1c20041b21.tar.gz
go-7c9b6b1ca249c14d358075da9678cd1c20041b21.zip
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations, because you can't SetOp across representation. Rewrite various code to avoid crossing those as-yet-unintroduced boundaries. In particular, code like x, y := v.(T) x, y := f() x, y := m[k] x, y := <-c starts out with Op = OAS2, and then it turns into a specific Op OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then later in walk is lowered to an OAS2 again. In the middle, the specific forms move the right-hand side from n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves it back. This is unnecessary and makes it hard for these all to share an underlying Node implementation. This CL changes these specific forms to leave the right-hand side in n.Rlist().First(). Similarly, OSELRECV2 is really just a temporary form of OAS2. This CL changes it to use same fields too. Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go, which formerly printed n.Right() instead of n.Rlist(). This results in a (correct!) update to cmd/compile/internal/logopt's expected output: ~R0 = <N> becomes ~R0 = &y.b. Passes buildall w/ toolstash -cmp. Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a Reviewed-on: https://go-review.googlesource.com/c/go/+/274105 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/logopt')
-rw-r--r--src/cmd/compile/internal/logopt/logopt_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/logopt/logopt_test.go b/src/cmd/compile/internal/logopt/logopt_test.go
index 51bab49518..4a6ed2fac9 100644
--- a/src/cmd/compile/internal/logopt/logopt_test.go
+++ b/src/cmd/compile/internal/logopt/logopt_test.go
@@ -132,7 +132,7 @@ func TestLogOpt(t *testing.T) {
// Check at both 1 and 8-byte alignments.
t.Run("Copy", func(t *testing.T) {
const copyCode = `package x
-func s128a1(x *[128]int8) [128]int8 {
+func s128a1(x *[128]int8) [128]int8 {
return *x
}
func s127a1(x *[127]int8) [127]int8 {
@@ -219,7 +219,7 @@ func s15a8(x *[15]int64) [15]int64 {
`{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":11},"end":{"line":4,"character":11}}},"message":"inlineLoc"},`+
`{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from \u0026y.b (address-of)"},`+
`{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":9},"end":{"line":4,"character":9}}},"message":"inlineLoc"},`+
- `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from ~R0 = \u003cN\u003e (assign-pair)"},`+
+ `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from ~R0 = \u0026y.b (assign-pair)"},`+
`{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":3},"end":{"line":9,"character":3}}},"message":"escflow: flow: ~r2 = ~R0:"},`+
`{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":3},"end":{"line":9,"character":3}}},"message":"escflow: from return (*int)(~R0) (return)"}]}`)
})