mirror of
https://github.com/golang/go
synced 2024-11-23 06:00:08 -07:00
cmd/compile: don't combine load+op if the op has SymAddr arguments
By combining the load+op, we may force the op to happen earlier in the store chain. That might force the SymAddr operation earlier, and in particular earlier than its corresponding VarDef. That leads to an invalid schedule, so avoid that. This is kind of a hack to work around the issue presented. I think the underlying problem, that LEAQ is not directly ordered with respect to its vardef, is the real problem. The benefit of this CL is that it fixes the immediate issue, is small, and obviously won't break anything. A real fix for this issue is much more invasive. The go binary is unchanged in size. This situation just doesn't occur very often. Fixes #28445 Change-Id: I13a765e13f075d5b6808a355ef3c43cdd7cd47b6 Reviewed-on: https://go-review.googlesource.com/c/153641 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
d1882c9866
commit
05bbec7357
@ -306,6 +306,8 @@ func (lv *Liveness) valueEffects(v *ssa.Value) (int32, liveEffect) {
|
|||||||
//
|
//
|
||||||
// Addr is a read also, as any subseqent holder of the pointer must be able
|
// Addr is a read also, as any subseqent holder of the pointer must be able
|
||||||
// to see all the values (including initialization) written so far.
|
// to see all the values (including initialization) written so far.
|
||||||
|
// This also prevents a variable from "coming back from the dead" and presenting
|
||||||
|
// stale pointers to the garbage collector. See issue 28445.
|
||||||
if e&(ssa.SymRead|ssa.SymAddr) != 0 {
|
if e&(ssa.SymRead|ssa.SymAddr) != 0 {
|
||||||
effect |= uevar
|
effect |= uevar
|
||||||
}
|
}
|
||||||
|
@ -264,6 +264,20 @@ func canMergeLoad(target, load *Value) bool {
|
|||||||
// to be very rare.
|
// to be very rare.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if v.Op.SymEffect()&SymAddr != 0 {
|
||||||
|
// This case prevents an operation that calculates the
|
||||||
|
// address of a local variable from being forced to schedule
|
||||||
|
// before its corresponding VarDef.
|
||||||
|
// See issue 28445.
|
||||||
|
// v1 = LOAD ...
|
||||||
|
// v2 = VARDEF
|
||||||
|
// v3 = LEAQ
|
||||||
|
// v4 = CMPQ v1 v3
|
||||||
|
// We don't want to combine the CMPQ with the load, because
|
||||||
|
// that would force the CMPQ to schedule before the VARDEF, which
|
||||||
|
// in turn requires the LEAQ to schedule before the VARDEF.
|
||||||
|
return false
|
||||||
|
}
|
||||||
if v.Type.IsMemory() {
|
if v.Type.IsMemory() {
|
||||||
if memPreds == nil {
|
if memPreds == nil {
|
||||||
// Initialise a map containing memory states
|
// Initialise a map containing memory states
|
||||||
|
16
test/fixedbugs/issue28445.go
Normal file
16
test/fixedbugs/issue28445.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
var fp = (**float64)(nil)
|
||||||
|
|
||||||
|
func f() {
|
||||||
|
switch fp {
|
||||||
|
case new(*float64):
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user