]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: turn jump tables off with -N
authorKeith Randall <khr@golang.org>
Thu, 14 Apr 2022 22:04:34 +0000 (15:04 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 15 Apr 2022 00:53:40 +0000 (00:53 +0000)
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>
src/cmd/compile/internal/walk/switch.go

index 6a2dbe1753e30a8dd8bb6d879da3a013554670c8..5067d5eb499167d5d43afa96b581faea72fa1ace 100644 (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 {