1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:30:24 -07:00

cmd/gc: enable racewalk of HMUL nodes.

A HMUL node appears in some constant divisions, but
to observe a false negative in race detector the divisor must be
suitably chosen to make sure the only memory access is
done for HMUL.

R=dvyukov
CC=golang-dev
https://golang.org/cl/7935045
This commit is contained in:
Rémy Oudompheng 2013-03-26 23:35:42 +01:00
parent 24c2c88b90
commit 5f9a9433ea
2 changed files with 11 additions and 11 deletions

View File

@ -241,6 +241,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
case OXOR: case OXOR:
case OSUB: case OSUB:
case OMUL: case OMUL:
case OHMUL:
case OEQ: case OEQ:
case ONE: case ONE:
case OLT: case OLT:
@ -379,19 +380,18 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
case OPARAM: // it appears only in fn->exit to copy heap params back case OPARAM: // it appears only in fn->exit to copy heap params back
case OCLOSUREVAR:// immutable pointer to captured variable case OCLOSUREVAR:// immutable pointer to captured variable
case ODOTMETH: // either part of CALLMETH or CALLPART (lowered to PTRLIT) case ODOTMETH: // either part of CALLMETH or CALLPART (lowered to PTRLIT)
case OINDREG: // at this stage, only n(SP) nodes from nodarg
case ODCL: // declarations (without value) cannot be races
case ODCLCONST:
case ODCLTYPE:
case OTYPE:
case ONONAME:
case OLITERAL:
case OSLICESTR: // always preceded by bounds checking, avoid double instrumentation.
goto ret; goto ret;
// unimplemented // unimplemented
case OSLICESTR:
case OAPPEND: case OAPPEND:
case ODCL:
case ODCLCONST:
case ODCLTYPE:
case OLITERAL:
case OTYPE:
case ONONAME:
case OINDREG:
case OHMUL:
goto ret; goto ret;
} }

View File

@ -339,11 +339,11 @@ func TestRaceDiv(t *testing.T) {
} }
func TestRaceDivConst(t *testing.T) { func TestRaceDivConst(t *testing.T) {
var x, y, z int var x, y, z uint32
ch := make(chan int, 2) ch := make(chan int, 2)
go func() { go func() {
x = y / 3 x = y / 3 // involves only a HMUL node
ch <- 1 ch <- 1
}() }()
go func() { go func() {