mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/gc: fix liveness for address-taken variables in inlined functions
The 'address taken' bit in a function variable was not propagating into the inlined copies, causing incorrect liveness information. LGTM=dsymonds, bradfitz R=golang-codereviews, bradfitz CC=dsymonds, golang-codereviews, iant, khr, r https://golang.org/cl/96670046
This commit is contained in:
parent
d646040fd1
commit
eb54079264
3 changed files with 72 additions and 0 deletions
32
test/live.go
32
test/live.go
|
|
@ -4,6 +4,9 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// liveness tests with inlining disabled.
|
||||
// see also live2.go.
|
||||
|
||||
package main
|
||||
|
||||
func f1() {
|
||||
|
|
@ -590,3 +593,32 @@ func f39c() (x [10]*int) {
|
|||
println() // ERROR "live at call to printnl: x"
|
||||
return
|
||||
}
|
||||
|
||||
// issue 8142: lost 'addrtaken' bit on inlined variables.
|
||||
// no inlining in this test, so just checking that non-inlined works.
|
||||
|
||||
type T40 struct {
|
||||
m map[int]int
|
||||
}
|
||||
|
||||
func newT40() *T40 {
|
||||
ret := T40{ // ERROR "live at call to makemap: &ret"
|
||||
make(map[int]int),
|
||||
}
|
||||
return &ret
|
||||
}
|
||||
|
||||
func bad40() {
|
||||
t := newT40()
|
||||
println()
|
||||
_ = t
|
||||
}
|
||||
|
||||
func good40() {
|
||||
ret := T40{ // ERROR "live at call to makemap: ret"
|
||||
make(map[int]int),
|
||||
}
|
||||
t := &ret
|
||||
println() // ERROR "live at call to printnl: ret"
|
||||
_ = t
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue