From 8354f6b5bb5baf03cb64dbf736c276f297ebea96 Mon Sep 17 00:00:00 2001 From: Jakub Ciolek Date: Tue, 10 Jan 2023 08:36:00 +0100 Subject: [PATCH] cmd/compile: use a boolean as a avoid clobbering flags mov marker The Value type implements Aux interface because it is being used as a "avoid clobbering flags" marker by amd64, x86 and s390x SSA parts. Create a boolean that implements the Aux interface. Use it as the marker instead. We no longer need Value to implement Aux. Resolves a TODO. See CL 275756 for more info. Change-Id: I8a1eddf7e738b8aa31e82f3c4c590bafd2cdc56b Reviewed-on: https://go-review.googlesource.com/c/go/+/461156 TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Run-TryBot: Jakub Ciolek Reviewed-by: Keith Randall Reviewed-by: Cherry Mui --- src/cmd/compile/internal/amd64/ssa.go | 2 +- src/cmd/compile/internal/s390x/ssa.go | 2 +- src/cmd/compile/internal/ssa/rewrite.go | 7 +++++++ src/cmd/compile/internal/ssa/value.go | 3 --- src/cmd/compile/internal/x86/ssa.go | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index cad410cfef..e256c0979a 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -30,7 +30,7 @@ func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { v := b.Values[i] if flive && (v.Op == ssa.OpAMD64MOVLconst || v.Op == ssa.OpAMD64MOVQconst) { // The "mark" is any non-nil Aux value. - v.Aux = v + v.Aux = ssa.AuxMark } if v.Type.IsFlags() { flive = false diff --git a/src/cmd/compile/internal/s390x/ssa.go b/src/cmd/compile/internal/s390x/ssa.go index ba50b00572..fc42557b03 100644 --- a/src/cmd/compile/internal/s390x/ssa.go +++ b/src/cmd/compile/internal/s390x/ssa.go @@ -26,7 +26,7 @@ func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { v := b.Values[i] if flive && v.Op == ssa.OpS390XMOVDconst { // The "mark" is any non-nil Aux value. - v.Aux = v + v.Aux = ssa.AuxMark } if v.Type.IsFlags() { flive = false diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 84bf2047d4..13095c0440 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -729,6 +729,13 @@ type Aux interface { CanBeAnSSAAux() } +// for now only used to mark moves that need to avoid clobbering flags +type auxMark bool + +func (auxMark) CanBeAnSSAAux() {} + +var AuxMark auxMark + // stringAux wraps string values for use in Aux. type stringAux string diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go index 643fa36e25..0567b3e214 100644 --- a/src/cmd/compile/internal/ssa/value.go +++ b/src/cmd/compile/internal/ssa/value.go @@ -554,9 +554,6 @@ func (v *Value) removeable() bool { return true } -// TODO(mdempsky): Shouldn't be necessary; see discussion at golang.org/cl/275756 -func (*Value) CanBeAnSSAAux() {} - // AutoVar returns a *Name and int64 representing the auto variable and offset within it // where v should be spilled. func AutoVar(v *Value) (*ir.Name, int64) { diff --git a/src/cmd/compile/internal/x86/ssa.go b/src/cmd/compile/internal/x86/ssa.go index 40a483fb24..ee95a4acaf 100644 --- a/src/cmd/compile/internal/x86/ssa.go +++ b/src/cmd/compile/internal/x86/ssa.go @@ -28,7 +28,7 @@ func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { v := b.Values[i] if flive && v.Op == ssa.Op386MOVLconst { // The "mark" is any non-nil Aux value. - v.Aux = v + v.Aux = ssa.AuxMark } if v.Type.IsFlags() { flive = false -- 2.50.0