From e7a1eb066bf6b2e349eeb875ec46561c6928a284 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 7 Jul 2023 17:06:23 -0400 Subject: [PATCH] cmd/compile: move racewalk comment to walk/race.go This comment got left behind in some refactoring and now refers to code "below" that is no longer below. Move it to be with the code it's referring to. Change-Id: I7f7bf0cf8b22c1f6e05ff12b8be71d18fb3359d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/521177 Reviewed-by: Michael Knyszek Auto-Submit: Austin Clements TryBot-Bypass: Austin Clements --- src/cmd/compile/internal/base/base.go | 20 -------------------- src/cmd/compile/internal/walk/race.go | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cmd/compile/internal/base/base.go b/src/cmd/compile/internal/base/base.go index dd73e50c66b..458481fa4ed 100644 --- a/src/cmd/compile/internal/base/base.go +++ b/src/cmd/compile/internal/base/base.go @@ -232,26 +232,6 @@ func Compiling(pkgs []string) bool { return false } -// The racewalk pass is currently handled in three parts. -// -// First, for flag_race, it inserts calls to racefuncenter and -// racefuncexit at the start and end (respectively) of each -// function. This is handled below. -// -// Second, during buildssa, it inserts appropriate instrumentation -// calls immediately before each memory load or store. This is handled -// by the (*state).instrument method in ssa.go, so here we just set -// the Func.InstrumentBody flag as needed. For background on why this -// is done during SSA construction rather than a separate SSA pass, -// see issue #19054. -// -// Third, we remove calls to racefuncenter and racefuncexit, for leaf -// functions without instrumented operations. This is done as part of -// ssa opt pass via special rule. - -// TODO(dvyukov): do not instrument initialization as writes: -// a := make([]int, 10) - // Do not instrument the following packages at all, // at best instrumentation would cause infinite recursion. var NoInstrumentPkgs = []string{ diff --git a/src/cmd/compile/internal/walk/race.go b/src/cmd/compile/internal/walk/race.go index 859e5c57f06..6384e162702 100644 --- a/src/cmd/compile/internal/walk/race.go +++ b/src/cmd/compile/internal/walk/race.go @@ -11,6 +11,26 @@ import ( "cmd/internal/src" ) +// The racewalk pass is currently handled in three parts. +// +// First, for flag_race, it inserts calls to racefuncenter and +// racefuncexit at the start and end (respectively) of each +// function. This is handled below. +// +// Second, during buildssa, it inserts appropriate instrumentation +// calls immediately before each memory load or store. This is handled +// by the (*state).instrument method in ssa.go, so here we just set +// the Func.InstrumentBody flag as needed. For background on why this +// is done during SSA construction rather than a separate SSA pass, +// see issue #19054. +// +// Third, we remove calls to racefuncenter and racefuncexit, for leaf +// functions without instrumented operations. This is done as part of +// ssa opt pass via special rule. + +// TODO(dvyukov): do not instrument initialization as writes: +// a := make([]int, 10) + func instrument(fn *ir.Func) { if fn.Pragma&ir.Norace != 0 || (fn.Linksym() != nil && fn.Linksym().ABIWrapper()) { return