aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/main.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-11-15 11:40:25 -0500
committerRuss Cox <rsc@golang.org>2020-11-24 14:58:10 +0000
commit7b144ed4f7a730f5c9375bca65010446ad9f4b73 (patch)
tree04150c00c58adc59ee9bd23fb20588207017c288 /src/cmd/compile/internal/gc/main.go
parentc754f25241134eaa68c8f26ed5372cadeb49ef89 (diff)
downloadgo-7b144ed4f7a730f5c9375bca65010446ad9f4b73.tar.gz
go-7b144ed4f7a730f5c9375bca65010446ad9f4b73.zip
[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>
Diffstat (limited to 'src/cmd/compile/internal/gc/main.go')
-rw-r--r--src/cmd/compile/internal/gc/main.go28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index a6963a3d66..61742fc8ce 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -1418,24 +1418,18 @@ func IsAlias(sym *types.Sym) bool {
return sym.Def != nil && asNode(sym.Def).Sym != sym
}
-// By default, assume any debug flags are incompatible with concurrent
-// compilation. A few are safe and potentially in common use for
-// normal compiles, though; return true for those.
+// concurrentFlagOk reports whether the current compiler flags
+// are compatible with concurrent compilation.
func concurrentFlagOk() bool {
- // Report whether any debug flag that would prevent concurrent
- // compilation is set, by zeroing out the allowed ones and then
- // checking if the resulting struct is zero.
- d := Debug
- d.B = 0 // disable bounds checking
- d.C = 0 // disable printing of columns in error messages
- d.e = 0 // no limit on errors; errors all come from non-concurrent code
- d.N = 0 // disable optimizations
- d.l = 0 // disable inlining
- 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{}
+ // TODO(rsc): Many of these are fine. Remove them.
+ return Debug.P == 0 &&
+ Debug.E == 0 &&
+ Debug.K == 0 &&
+ Debug.L == 0 &&
+ Debug.h == 0 &&
+ Debug.j == 0 &&
+ Debug.m == 0 &&
+ Debug.r == 0
}
func concurrentBackendAllowed() bool {