1
0
mirror of https://github.com/golang/go synced 2024-11-20 03:34:40 -07:00

cmd/gc: instrument blocks for race detection.

It happens that blocks are used for function calls in a
quite low-level way so they cannot be instrumented as
usual.

Blocks are also used for inlined functions.

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/6821068
This commit is contained in:
Rémy Oudompheng 2012-11-03 00:11:06 +01:00
parent 600de1fb3d
commit c46f1f40da

View File

@ -88,6 +88,7 @@ static void
racewalknode(Node **np, NodeList **init, int wr, int skip)
{
Node *n, *n1;
NodeList *fini;
n = *np;
@ -116,8 +117,28 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
goto ret;
case OBLOCK:
// leads to crashes.
//racewalklist(n->list, nil);
if(n->list == nil)
goto ret;
switch(n->list->n->op) {
case OCALLFUNC:
case OCALLMETH:
case OCALLINTER:
// Blocks are used for multiple return function calls.
// x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]}
// We don't want to instrument between the statements because it will
// smash the results.
racewalknode(&n->list->n, &n->ninit, 0, 0);
fini = nil;
racewalklist(n->list->next, &fini);
n->list = concat(n->list, fini);
break;
default:
// Ordinary block, for loop initialization or inlined bodies.
racewalklist(n->list, nil);
break;
}
goto ret;
case ODEFER: