mirror of
https://github.com/golang/go
synced 2024-11-26 11:58:07 -07:00
cmd/compile: don't emit write barriers for offsets of global addresses
Currently, write barriers aren't emitted for global addresses, but they are emitted for addresses offset of global addresses. This CL changes IsGlobalAddr to recognize offsets of global addresses as globals too, removing write barriers for staticuint64s based addresses. The logic added is the same as used in IsStackAddr. Updates #37612 Change-Id: I537579f85b9ad02987d94f3ee0b4508b90097959 Reviewed-on: https://go-review.googlesource.com/c/go/+/342129 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
3081f817da
commit
6b9e3f883e
@ -552,6 +552,9 @@ func IsStackAddr(v *Value) bool {
|
||||
|
||||
// IsGlobalAddr reports whether v is known to be an address of a global (or nil).
|
||||
func IsGlobalAddr(v *Value) bool {
|
||||
for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy {
|
||||
v = v.Args[0]
|
||||
}
|
||||
if v.Op == OpAddr && v.Args[0].Op == OpSB {
|
||||
return true // address of a global
|
||||
}
|
||||
|
@ -289,3 +289,17 @@ func f27(p *int) []interface{} {
|
||||
p, // ERROR "write barrier"
|
||||
}
|
||||
}
|
||||
|
||||
var g28 [256]uint64
|
||||
|
||||
func f28() []interface{} {
|
||||
return []interface{}{
|
||||
false, // no write barrier
|
||||
true, // no write barrier
|
||||
0, // no write barrier
|
||||
1, // no write barrier
|
||||
uint8(127), // no write barrier
|
||||
int8(-4), // no write barrier
|
||||
&g28[5], // no write barrier
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user