]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: racewalk: fix instrumentation of ninit lists
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 1 Nov 2012 18:11:12 +0000 (22:11 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 1 Nov 2012 18:11:12 +0000 (22:11 +0400)
The idea is to (1) process ninit of all nodes,
and (2) put instrumentation of ninit into the nodes themselves (not the top-level statement ninit).
Fixes #4304.

R=golang-dev, rsc
CC=golang-dev, lvd
https://golang.org/cl/6818049

src/cmd/gc/racewalk.c

index 9a01abb0977a210b509ab24651ccc865a433d411..3e0feffd5a55bc10780bc0a37ab161e109b29768 100644 (file)
@@ -89,6 +89,8 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                        opnames[n->op], n->left, n->right, n->right ? n->right->type : nil, n->type, n->class);
        setlineno(n);
 
+       racewalklist(n->ninit, nil);
+
        switch(n->op) {
        default:
                fatal("racewalk: unknown node type %O", n->op);
@@ -100,7 +102,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
        case OAS2RECV:
        case OAS2FUNC:
        case OAS2MAPR:
-               racewalklist(n->ninit, init);
                racewalknode(&n->left, init, 1, 0);
                racewalknode(&n->right, init, 0, 0);
                goto ret;
@@ -115,7 +116,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                goto ret;
 
        case OFOR:
-               racewalklist(n->ninit, nil);
                if(n->ntest != N)
                        racewalklist(n->ntest->ninit, nil);
                racewalknode(&n->nincr, init, wr, 0);
@@ -123,7 +123,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                goto ret;
 
        case OIF:
-               racewalklist(n->ninit, nil);
                racewalknode(&n->ntest, &n->ninit, wr, 0);
                racewalklist(n->nbody, nil);
                racewalklist(n->nelse, nil);
@@ -140,7 +139,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
 
        case OCALLFUNC:
                racewalknode(&n->left, init, 0, 0);
-               racewalklist(n->ninit, init);
                racewalklist(n->list, init);
                goto ret;
 
@@ -159,7 +157,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                goto ret;
 
        case OSWITCH:
-               racewalklist(n->ninit, nil);
                if(n->ntest->op == OTYPESW)
                        // don't bother, we have static typization
                        return;
@@ -168,7 +165,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
                goto ret;
 
        case OEMPTY:
-               racewalklist(n->ninit, nil);
                goto ret;
 
        case ONOT:
@@ -274,7 +270,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
        case OSLICE:
        case OSLICEARR:
                // Seems to only lead to double instrumentation.
-               //racewalklist(n->ninit, init);
                //racewalknode(&n->left, init, 0, 0);
                //racewalklist(n->list, init);
                goto ret;