aboutsummaryrefslogtreecommitdiff
path: root/test/live.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2019-09-03 23:24:35 +0700
committerMatthew Dempsky <mdempsky@google.com>2019-09-03 19:33:04 +0000
commitd2f958d8d11bcf62fe572885133bfaef41307a14 (patch)
tree043de28a03afa2f716e8bdfb8e226f8bc9e31c53 /test/live.go
parent9da7abd2ebd07d32484277adac75c45b66f504c1 (diff)
downloadgo-d2f958d8d11bcf62fe572885133bfaef41307a14.tar.gz
go-d2f958d8d11bcf62fe572885133bfaef41307a14.zip
cmd/compile: extend ssa.go to handle 1-element array and 1-field struct
Assinging to 1-element array/1-field struct variable is considered clobbering the whole variable. By emitting OpVarDef in this case, liveness analysis can now know the variable is redefined. Also, the isfat is not necessary anymore, and will be removed in follow up CL. Fixes #33916 Change-Id: Iece0d90b05273f333d59d6ee5b12ee7dc71908c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/192979 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/live.go')
-rw-r--r--test/live.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/live.go b/test/live.go
index ec51193725..b6e6d93f5f 100644
--- a/test/live.go
+++ b/test/live.go
@@ -659,7 +659,7 @@ func bad40() {
func good40() {
ret := T40{} // ERROR "stack object ret T40$"
- ret.m = make(map[int]int) // ERROR "live at call to fastrand: .autotmp_[0-9]+ ret$" "stack object .autotmp_[0-9]+ map.hdr\[int\]int$"
+ ret.m = make(map[int]int) // ERROR "live at call to fastrand: .autotmp_[0-9]+$" "stack object .autotmp_[0-9]+ map.hdr\[int\]int$"
t := &ret
printnl() // ERROR "live at call to printnl: ret$"
// Note: ret is live at the printnl because the compiler moves &ret
@@ -704,3 +704,14 @@ func f42() {
//go:noescape
func f43(a []*int)
+
+// Assigning to a sub-element that makes up an entire local variable
+// should clobber that variable.
+func f44(f func() [2]*int) interface{} { // ERROR "live at entry to f44: f"
+ type T struct {
+ s [1][2]*int
+ }
+ ret := T{}
+ ret.s[0] = f()
+ return ret // ERROR "stack object .autotmp_5 T"
+}