mirror of
https://github.com/golang/go
synced 2024-11-26 21:41:33 -07:00
adfa8b8691
If the address of an auto reaches a phi then any further stores to the pointer represented by the phi probably need to be kept. This is because stores to the other arguments to the phi may be visible to the program. Fixes #26153. Change-Id: Ic506c6c543bf70d792e5b1a64bdde1e5fdf1126a Reviewed-on: https://go-review.googlesource.com/121796 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
30 lines
504 B
Go
30 lines
504 B
Go
// run
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Issue 26153. The write to ps was incorrectly
|
|
// removed by the dead auto elimination pass.
|
|
|
|
package main
|
|
|
|
const hello = "hello world"
|
|
|
|
func main() {
|
|
var s string
|
|
mangle(&s)
|
|
if s != hello {
|
|
panic("write incorrectly elided")
|
|
}
|
|
}
|
|
|
|
//go:noinline
|
|
func mangle(ps *string) {
|
|
if ps == nil {
|
|
var s string
|
|
ps = &s
|
|
}
|
|
*ps = hello
|
|
}
|