diff options
| author | Austin Clements <austin@google.com> | 2023-07-07 17:01:47 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2023-08-22 19:18:34 +0000 |
| commit | 56b3b244fdd7a50fcd9ffb20d7cfdbfae3af81f0 (patch) | |
| tree | e209196818501db68c0a8f798bba7173d5c0bcaf /src/cmd/compile | |
| parent | 83e0704c50c4269d90ec654b6590ae4db554f4eb (diff) | |
| download | go-56b3b244fdd7a50fcd9ffb20d7cfdbfae3af81f0.tar.xz | |
cmd/internal/objabi,cmd/compile: move NoInstrumentPkgs and NoRacePkgs to PkgSpecials
This consolidates the NoInstrumentPkgs and NoRacePkgs lists into the
objabi.LookupPkgSpecial mechanism.
Change-Id: I411654afdd690fb01c412e7e8b57ddfbe85415e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521702
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Diffstat (limited to 'src/cmd/compile')
| -rw-r--r-- | src/cmd/compile/internal/base/base.go | 41 | ||||
| -rw-r--r-- | src/cmd/compile/internal/gc/main.go | 2 | ||||
| -rw-r--r-- | src/cmd/compile/internal/types/type.go | 15 | ||||
| -rw-r--r-- | src/cmd/compile/internal/walk/race.go | 3 |
4 files changed, 6 insertions, 55 deletions
diff --git a/src/cmd/compile/internal/base/base.go b/src/cmd/compile/internal/base/base.go index 841241efb1..ee3772c5ca 100644 --- a/src/cmd/compile/internal/base/base.go +++ b/src/cmd/compile/internal/base/base.go @@ -219,44 +219,3 @@ func AdjustStartingHeap(requestedHeapGoal uint64) { forEachGC(adjustFunc) } - -func Compiling(pkgs []string) bool { - if Ctxt.Pkgpath != "" { - for _, p := range pkgs { - if Ctxt.Pkgpath == p { - return true - } - } - } - - return false -} - -// Do not instrument the following packages at all, -// at best instrumentation would cause infinite recursion. -var NoInstrumentPkgs = []string{ - "runtime/internal/atomic", - "runtime/internal/math", - "runtime/internal/sys", - "runtime/internal/syscall", - "runtime", - "runtime/race", - "runtime/msan", - "runtime/asan", - "internal/cpu", - "internal/abi", - // We omit bytealg even though it's imported by runtime because it also - // backs a lot of package bytes. Currently we don't have a way to omit race - // instrumentation when used from the runtime while keeping race - // instrumentation when used from user code. Somehow this doesn't seem to - // cause problems, though we may be skating on thin ice. See #61204. - //"internal/bytealg", - "internal/coverage/rtcov", - "internal/godebugs", - "internal/goexperiment", - "internal/goos", -} - -// Don't insert racefuncenter/racefuncexit into the following packages. -// Memory accesses in the packages are either uninteresting or will cause false positives. -var NoRacePkgs = []string{"sync", "sync/atomic"} diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index f38438b7b3..05f0340d39 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -151,7 +151,7 @@ func Main(archInit func(*ssagen.ArchInfo)) { symABIs.ReadSymABIs(base.Flag.SymABIs) } - if base.Compiling(base.NoInstrumentPkgs) { + if objabi.LookupPkgSpecial(base.Ctxt.Pkgpath).NoInstrument { base.Flag.Race = false base.Flag.MSan = false base.Flag.ASan = false diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index bd63f651a5..696e8a5bc1 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -6,6 +6,7 @@ package types import ( "cmd/compile/internal/base" + "cmd/internal/objabi" "cmd/internal/src" "fmt" "internal/types/errors" @@ -1862,23 +1863,13 @@ func ReflectSymName(s *Sym) string { // IsNoInstrumentPkg reports whether p is a package that // should not be instrumented. func IsNoInstrumentPkg(p *Pkg) bool { - for _, np := range base.NoInstrumentPkgs { - if p.Path == np { - return true - } - } - return false + return objabi.LookupPkgSpecial(p.Path).NoInstrument } // IsNoRacePkg reports whether p is a package that // should not be race instrumented. func IsNoRacePkg(p *Pkg) bool { - for _, np := range base.NoRacePkgs { - if p.Path == np { - return true - } - } - return false + return objabi.LookupPkgSpecial(p.Path).NoRaceFunc } // ReceiverBaseType returns the underlying type, if any, diff --git a/src/cmd/compile/internal/walk/race.go b/src/cmd/compile/internal/walk/race.go index 6384e16270..972c878b30 100644 --- a/src/cmd/compile/internal/walk/race.go +++ b/src/cmd/compile/internal/walk/race.go @@ -8,6 +8,7 @@ import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/types" + "cmd/internal/objabi" "cmd/internal/src" ) @@ -36,7 +37,7 @@ func instrument(fn *ir.Func) { return } - if !base.Flag.Race || !base.Compiling(base.NoRacePkgs) { + if !base.Flag.Race || !objabi.LookupPkgSpecial(base.Ctxt.Pkgpath).NoRaceFunc { fn.SetInstrumentBody(true) } |
