Commit b11f85a8 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

cmd/gc: racewalk: fix instrumentation of ninit lists

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