mirror of
https://github.com/golang/go
synced 2024-11-24 06:40:17 -07:00
cmd/compile: don't generate race calls for zero-sized values
One example of a heavily-used zero-size value is encoding/binary.BigEndian. Change-Id: I8e873c447e154ab2ca61b7315df774693891270c Reviewed-on: https://go-review.googlesource.com/59330 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
parent
99da8730b0
commit
b046878018
@ -462,6 +462,15 @@ func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
|
||||
return false
|
||||
}
|
||||
t := n.Type
|
||||
// dowidth may not have been called for PEXTERN.
|
||||
dowidth(t)
|
||||
w := t.Width
|
||||
if w == BADWIDTH {
|
||||
Fatalf("instrument: %v badwidth", t)
|
||||
}
|
||||
if w == 0 {
|
||||
return false // can't race on zero-sized things
|
||||
}
|
||||
if isartificial(n) {
|
||||
return false
|
||||
}
|
||||
@ -494,24 +503,12 @@ func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
|
||||
if wr != 0 {
|
||||
name = "msanwrite"
|
||||
}
|
||||
// dowidth may not have been called for PEXTERN.
|
||||
dowidth(t)
|
||||
w := t.Width
|
||||
if w == BADWIDTH {
|
||||
Fatalf("instrument: %v badwidth", t)
|
||||
}
|
||||
f = mkcall(name, nil, init, uintptraddr(n), nodintconst(w))
|
||||
} else if flag_race && (t.IsStruct() || t.IsArray()) {
|
||||
name := "racereadrange"
|
||||
if wr != 0 {
|
||||
name = "racewriterange"
|
||||
}
|
||||
// dowidth may not have been called for PEXTERN.
|
||||
dowidth(t)
|
||||
w := t.Width
|
||||
if w == BADWIDTH {
|
||||
Fatalf("instrument: %v badwidth", t)
|
||||
}
|
||||
f = mkcall(name, nil, init, uintptraddr(n), nodintconst(w))
|
||||
} else if flag_race {
|
||||
name := "raceread"
|
||||
|
Loading…
Reference in New Issue
Block a user