aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/liveness
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2020-12-23 20:29:28 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2020-12-23 15:15:29 +0000
commit9eeed291bcfbf6de4d64abd39eb1eb66cdf9fbb2 (patch)
treebc955f060257541d199b7bf9045ca1b402c95537 /src/cmd/compile/internal/liveness
parentd1d64e4cea41bf908152e6a9c45980946e7825a2 (diff)
downloadgo-9eeed291bcfbf6de4d64abd39eb1eb66cdf9fbb2.tar.gz
go-9eeed291bcfbf6de4d64abd39eb1eb66cdf9fbb2.zip
[dev.regabi] cmd/compile: eliminate usage of ir.Node in liveness
All function parameters and return values in liveness have explicit *ir.Name type, so use it directly instead of casting from ir.Node. While at it, rename "affectedNode" to "affectedVar" to reflect this change. Passes buildall w/ toolstash -cmp. Change-Id: Id927e817a92ddb551a029064a2a54e020ca27074 Reviewed-on: https://go-review.googlesource.com/c/go/+/279434 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/liveness')
-rw-r--r--src/cmd/compile/internal/liveness/plive.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/liveness/plive.go b/src/cmd/compile/internal/liveness/plive.go
index 785a3a29de..cf4debb795 100644
--- a/src/cmd/compile/internal/liveness/plive.go
+++ b/src/cmd/compile/internal/liveness/plive.go
@@ -179,11 +179,7 @@ type progeffectscache struct {
// nor do we care about non-local variables,
// nor do we care about empty structs (handled by the pointer check),
// nor do we care about the fake PAUTOHEAP variables.
-func ShouldTrack(nn ir.Node) bool {
- if nn.Op() != ir.ONAME {
- return false
- }
- n := nn.(*ir.Name)
+func ShouldTrack(n *ir.Name) bool {
return (n.Class_ == ir.PAUTO || n.Class_ == ir.PPARAM || n.Class_ == ir.PPARAMOUT) && n.Type().HasPointers()
}
@@ -248,19 +244,17 @@ const (
// liveness effects v has on that variable.
// If v does not affect any tracked variables, it returns -1, 0.
func (lv *liveness) valueEffects(v *ssa.Value) (int32, liveEffect) {
- n, e := affectedNode(v)
- if e == 0 || n == nil || n.Op() != ir.ONAME { // cheapest checks first
+ n, e := affectedVar(v)
+ if e == 0 || n == nil { // cheapest checks first
return -1, 0
}
-
- nn := n.(*ir.Name)
// AllocFrame has dropped unused variables from
// lv.fn.Func.Dcl, but they might still be referenced by
// OpVarFoo pseudo-ops. Ignore them to prevent "lost track of
// variable" ICEs (issue 19632).
switch v.Op {
case ssa.OpVarDef, ssa.OpVarKill, ssa.OpVarLive, ssa.OpKeepAlive:
- if !nn.Name().Used() {
+ if !n.Name().Used() {
return -1, 0
}
}
@@ -283,14 +277,14 @@ func (lv *liveness) valueEffects(v *ssa.Value) (int32, liveEffect) {
return -1, 0
}
- if pos, ok := lv.idx[nn]; ok {
+ if pos, ok := lv.idx[n]; ok {
return pos, effect
}
return -1, 0
}
-// affectedNode returns the *Node affected by v
-func affectedNode(v *ssa.Value) (ir.Node, ssa.SymEffect) {
+// affectedVar returns the *ir.Name node affected by v
+func affectedVar(v *ssa.Value) (*ir.Name, ssa.SymEffect) {
// Special cases.
switch v.Op {
case ssa.OpLoadReg: