aboutsummaryrefslogtreecommitdiff
path: root/test/live2.go
diff options
context:
space:
mode:
authorMichael Munday <mike.munday@ibm.com>2017-03-29 14:01:41 -0400
committerMichael Munday <mike.munday@ibm.com>2017-08-24 16:53:56 +0000
commit744ebfde0460e1d8fff10672e4d1e8d9ece52556 (patch)
tree30f9eca8178f7ce2b7534ab394e0e1dac4e42e60 /test/live2.go
parent18b48afec9be0a1da4b23bebace0dc9f081dcee1 (diff)
downloadgo-744ebfde0460e1d8fff10672e4d1e8d9ece52556.tar.gz
go-744ebfde0460e1d8fff10672e4d1e8d9ece52556.zip
cmd/compile: eliminate stores to unread auto variables
This is a crude compiler pass to eliminate stores to auto variables that are only ever written to. Eliminates an unnecessary store to x from the following code: func f() int { var x := 1 return *(&x) } Fixes #19765. Change-Id: If2c63a8ae67b8c590b6e0cc98a9610939a3eeffa Reviewed-on: https://go-review.googlesource.com/38746 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/live2.go')
-rw-r--r--test/live2.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/live2.go b/test/live2.go
index 6138d369c9..5c5706d225 100644
--- a/test/live2.go
+++ b/test/live2.go
@@ -14,6 +14,9 @@ package main
func printnl()
+//go:noescape
+func useT40(*T40)
+
type T40 struct {
m map[int]int
}
@@ -27,7 +30,7 @@ func newT40() *T40 {
func bad40() {
t := newT40() // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$"
printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$"
- _ = t
+ useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$"
}
func good40() {
@@ -35,5 +38,5 @@ func good40() {
ret.m = make(map[int]int) // ERROR "live at call to makemap: .autotmp_[0-9]+ ret$"
t := &ret
printnl() // ERROR "live at call to printnl: .autotmp_[0-9]+ ret$"
- _ = t
+ useT40(t) // ERROR "live at call to useT40: .autotmp_[0-9]+ ret$"
}