]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: insert instrumentation during SSA building
authorMatthew Dempsky <mdempsky@google.com>
Tue, 27 Mar 2018 20:50:08 +0000 (13:50 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 9 Apr 2018 18:40:55 +0000 (18:40 +0000)
commit17df5ed910cab9c68bc781b06d83b8db3fd0f75c
tree3cb147db3c93fda7245f8949318309c6538a5302
parent31700b83b5d9bdc2ddc474fd72b809a7b585d6da
cmd/compile: insert instrumentation during SSA building

Insert appropriate race/msan calls before each memory operation during
SSA construction.

This is conceptually simple, but subtle because we need to be careful
that inserted instrumentation calls don't clobber arguments that are
currently being prepared for a user function call.

reorder1 already handles introducing temporary variables for arguments
in some cases. This CL changes it to use them for all arguments when
instrumenting.

Also, we can't SSA struct types with more than one field while
instrumenting. Otherwise, concurrent uses of disjoint fields within an
SSA-able struct can introduce false races.

This is both somewhat better and somewhat worse than the old racewalk
instrumentation pass. We're now able to easily recognize cases like
constructing non-escaping closures on the stack or accessing closure
variables don't need instrumentation calls. On the other hand,
spilling escaping parameters to the heap now results in an
instrumentation call.

Overall, this CL results in a small net reduction in the number of
instrumentation calls, but a small net increase in binary size for
instrumented executables. cmd/go ends up with 5.6% fewer calls, but a
2.4% larger binary.

Fixes #19054.

Change-Id: I70d1dd32ad6340e6fdb691e6d5a01452f58e97f3
Reviewed-on: https://go-review.googlesource.com/102817
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/racewalk.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/walk.go
src/cmd/compile/internal/ssa/writebarrier.go