mirror of
https://github.com/golang/go
synced 2024-11-15 02:40:32 -07:00
0029cd479e
Lack of a well-defined order between VarDef and related address operations sometimes causes problems with store order and write barrier transformations; glitches in the order are made irreparable (by later optimizations) if the two parts of the glitch straddle a split in the original block caused by insertion of a write barrier diamond. Fix this by creating a LocalAddr for addresses of locals (what VarDef matters for) that takes a memory input to help make the order explicit. Addr is modified to only be legal for SB operand, so there is no overlap between Addr and LocalAddr uses (there may be some downstream cleanup from this). Changes to generic.rules and rewrite.go ensure that codegen tests continue to pass; CSE of LocalAddr is impaired, not quite sure of the cost. Fixes #26105. Change-Id: Id4192b4440aa4e9d7ba54a465c456df9b530b515 Reviewed-on: https://go-review.googlesource.com/122483 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
26 lines
543 B
Go
26 lines
543 B
Go
// compile
|
|
|
|
// 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.
|
|
|
|
// Triggers a bug in writebarrier, which inserts one
|
|
// between (first block) OpAddr x and (second block) a VarDef x,
|
|
// which are then in the wrong order and unable to be
|
|
// properly scheduled.
|
|
|
|
package q
|
|
|
|
var S interface{}
|
|
|
|
func F(n int) {
|
|
fun := func(x int) int {
|
|
S = 1
|
|
return n
|
|
}
|
|
i := fun(([]int{})[n])
|
|
|
|
var fc [2]chan int
|
|
S = (([1][2]chan int{fc})[i][i])
|
|
}
|