mirror of
https://github.com/golang/go
synced 2024-11-26 09:48:14 -07:00
[dev.regabi] cmd/compile: rewrite concurrentFlagOk to be clearer
The current implementation copies Debug, clears a bunch of flags that are meant to be considered OK, and then checks the result against the zero value. But more flags are cleared than remain: it's easier to write and to understand to just check the ones that need checking. This phrasing also makes it safe to move more flags into the struct. It turns out that some of the flags being checked should probably not be checked, but this CL is meant to be a strict semantic no-op, so left a TODO to clean up the function a bit more later. Change-Id: I7afe6d7b32b5b889c40dd339568e8602e02df9bc Reviewed-on: https://go-review.googlesource.com/c/go/+/271666 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
c754f25241
commit
7b144ed4f7
@ -1418,24 +1418,18 @@ func IsAlias(sym *types.Sym) bool {
|
|||||||
return sym.Def != nil && asNode(sym.Def).Sym != sym
|
return sym.Def != nil && asNode(sym.Def).Sym != sym
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default, assume any debug flags are incompatible with concurrent
|
// concurrentFlagOk reports whether the current compiler flags
|
||||||
// compilation. A few are safe and potentially in common use for
|
// are compatible with concurrent compilation.
|
||||||
// normal compiles, though; return true for those.
|
|
||||||
func concurrentFlagOk() bool {
|
func concurrentFlagOk() bool {
|
||||||
// Report whether any debug flag that would prevent concurrent
|
// TODO(rsc): Many of these are fine. Remove them.
|
||||||
// compilation is set, by zeroing out the allowed ones and then
|
return Debug.P == 0 &&
|
||||||
// checking if the resulting struct is zero.
|
Debug.E == 0 &&
|
||||||
d := Debug
|
Debug.K == 0 &&
|
||||||
d.B = 0 // disable bounds checking
|
Debug.L == 0 &&
|
||||||
d.C = 0 // disable printing of columns in error messages
|
Debug.h == 0 &&
|
||||||
d.e = 0 // no limit on errors; errors all come from non-concurrent code
|
Debug.j == 0 &&
|
||||||
d.N = 0 // disable optimizations
|
Debug.m == 0 &&
|
||||||
d.l = 0 // disable inlining
|
Debug.r == 0
|
||||||
d.w = 0 // all printing happens before compilation
|
|
||||||
d.W = 0 // all printing happens before compilation
|
|
||||||
d.S = 0 // printing disassembly happens at the end (but see concurrentBackendAllowed below)
|
|
||||||
|
|
||||||
return d == DebugFlags{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func concurrentBackendAllowed() bool {
|
func concurrentBackendAllowed() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user