1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:54:39 -07:00

cmd/compile: clarify a few redundant deletions of internal/ssagen.state.vars

Fixes #58729

The reason why these deletions exist is that the old state.variable method
will assign the new value to the given key of map when the key doesn't exist,
but after this commit: 5a6e511c61 (diff-e754f9fc8eaf878714250cfc03844eb3b58185ac806a8c1c4f9fbabd86cda921L3972)
the state.variable doesn't do that anymore, thus these deletions became redundant.

Change-Id: Ie6e2471ca445f907a2bb1607c293f9301f0d73e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/471355
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Andy Pan 2023-02-25 18:31:13 +08:00 committed by Gopher Robot
parent 642542cb3c
commit 24017148ca

View File

@ -7,7 +7,6 @@ package ssagen
import (
"bufio"
"bytes"
"cmd/compile/internal/abi"
"fmt"
"go/constant"
"html"
@ -17,6 +16,7 @@ import (
"sort"
"strings"
"cmd/compile/internal/abi"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/liveness"
@ -3521,6 +3521,10 @@ func (s *state) append(n *ir.CallExpr, inplace bool) *ssa.Value {
}
}
// The following deletions have no practical effect at this time
// because state.vars has been reset by the preceding state.startBlock.
// They only enforce the fact that these variables are no longer need in
// the current scope.
delete(s.vars, ptrVar)
delete(s.vars, lenVar)
if !inplace {
@ -6379,7 +6383,7 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
idata := s.newValue1(ssa.OpIData, byteptr, iface)
res = s.newValue2(ssa.OpIMake, dst, s.variable(typVar, byteptr), idata)
resok = cond
delete(s.vars, typVar)
delete(s.vars, typVar) // no practical effect, just to indicate typVar is no longer live.
return
}
// converting to a nonempty interface needs a runtime call.
@ -6504,12 +6508,12 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
s.startBlock(bEnd)
if tmp == nil {
res = s.variable(valVar, dst)
delete(s.vars, valVar)
delete(s.vars, valVar) // no practical effect, just to indicate typVar is no longer live.
} else {
res = s.load(dst, addr)
}
resok = s.variable(okVar, types.Types[types.TBOOL])
delete(s.vars, okVar)
delete(s.vars, okVar) // ditto
return res, resok
}