Commit b0468780 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarDmitry Vyukov <dvyukov@google.com>
parent 99da8730
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment