1
0
mirror of https://github.com/golang/go synced 2024-11-24 06:30:22 -07:00

cmd/compile: turn jump tables off with -N

The noopt builder is broken, because with -N we get two OpSB opcodes
(one for the function as a whole, one introduced by the jumptable
rewrite rule), and they fight each other for a register.

Without -N, the two OpSB get CSEd, so optimized builds are ok.

Maybe we fix regalloc to deal with this case, but it's simpler
(and maybe more correct?) to disable jump tables with -N.

Change-Id: I75c87f12de6262955d1df787f47c53de976f8a5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/400455
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Keith Randall 2022-04-14 15:04:34 -07:00 committed by Gopher Robot
parent cc43e191ce
commit 78bea702cd

View File

@ -289,7 +289,7 @@ func (s *exprSwitch) tryJumpTable(cc []exprClause, out *ir.Nodes) bool {
const minCases = 8 // have at least minCases cases in the switch
const minDensity = 4 // use at least 1 out of every minDensity entries
if !go119UseJumpTables || !ssagen.Arch.LinkArch.CanJumpTable {
if !go119UseJumpTables || base.Flag.N != 0 || !ssagen.Arch.LinkArch.CanJumpTable {
return false
}
if len(cc) < minCases {