From 78bea702cd38ac5004a97f110e7f659336a04d57 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 14 Apr 2022 15:04:34 -0700 Subject: [PATCH] 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 Reviewed-by: Keith Randall Auto-Submit: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/cmd/compile/internal/walk/switch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/walk/switch.go b/src/cmd/compile/internal/walk/switch.go index 6a2dbe1753e..5067d5eb499 100644 --- a/src/cmd/compile/internal/walk/switch.go +++ b/src/cmd/compile/internal/walk/switch.go @@ -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 {