]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: use a boolean as a avoid clobbering flags mov marker
authorJakub Ciolek <jakub@ciolek.dev>
Tue, 10 Jan 2023 07:36:00 +0000 (08:36 +0100)
committerKeith Randall <khr@golang.org>
Fri, 20 Jan 2023 05:01:15 +0000 (05:01 +0000)
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 <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/s390x/ssa.go
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/value.go
src/cmd/compile/internal/x86/ssa.go

index cad410cfefbcf7d4add713850f68115d6b5f7ab9..e256c0979a289fffff7d6e9aadfbcf57fea33acf 100644 (file)
@@ -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
index ba50b005727a2ec5d6e7ce1e024ff80d367ec131..fc42557b039a7800c2dcd1aace0b07bcd762ce0b 100644 (file)
@@ -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
index 84bf2047d42d97f9bbfd030bc880539c8c7989a6..13095c0440fdf89163187518d3ba9c709e40c25d 100644 (file)
@@ -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
 
index 643fa36e251d13a8ab841ba43643e35cbf07cd24..0567b3e21436961905334eb912c273418facb13e 100644 (file)
@@ -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) {
index 40a483fb24fa51c6768489dc81e9e5284877839f..ee95a4acaf59d3681e3b899da6f2bab356adbe83 100644 (file)
@@ -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