]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: enable racewalk of HMUL nodes.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 26 Mar 2013 22:35:42 +0000 (23:35 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 26 Mar 2013 22:35:42 +0000 (23:35 +0100)
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

src/cmd/gc/racewalk.c
src/pkg/runtime/race/testdata/mop_test.go

index 80257985ddd32d55ee9df9387490bc381b40678d..fee5cf42264c6865f874a195e24a7ccb9f3b8c29 100644 (file)
@@ -241,6 +241,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
        case OXOR:
        case OSUB:
        case OMUL:
+       case OHMUL:
        case OEQ:
        case ONE:
        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 OCLOSUREVAR:// immutable pointer to captured variable
        case ODOTMETH:   // either part of CALLMETH or CALLPART (lowered to PTRLIT)
-               goto ret;
-
-       // unimplemented
-       case OSLICESTR:
-       case OAPPEND:
-       case ODCL:
+       case OINDREG:    // at this stage, only n(SP) nodes from nodarg
+       case ODCL:       // declarations (without value) cannot be races
        case ODCLCONST:
        case ODCLTYPE:
-       case OLITERAL:
        case OTYPE:
        case ONONAME:
-       case OINDREG:
-       case OHMUL:
+       case OLITERAL:
+       case OSLICESTR:  // always preceded by bounds checking, avoid double instrumentation.
+               goto ret;
+
+       // unimplemented
+       case OAPPEND:
                goto ret;
        }
 
index f0fe868ccbd8bc5459033d51de7b2253b30e9b04..1a7ed96249d5f202a4907563e5f3495156ae496d 100644 (file)
@@ -339,11 +339,11 @@ func TestRaceDiv(t *testing.T) {
 }
 
 func TestRaceDivConst(t *testing.T) {
-       var x, y, z int
+       var x, y, z uint32
        ch := make(chan int, 2)
 
        go func() {
-               x = y / 3
+               x = y / 3 // involves only a HMUL node
                ch <- 1
        }()
        go func() {