]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: rip out support for OpVarKill from ssa backend
authorKeith Randall <khr@golang.org>
Fri, 22 Jul 2022 22:08:07 +0000 (15:08 -0700)
committerKeith Randall <khr@golang.org>
Thu, 18 Aug 2022 17:36:52 +0000 (17:36 +0000)
Change-Id: I008479a7516d8379186ce630748e503d94d3b1e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/419235
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

12 files changed:
src/cmd/compile/internal/liveness/arg.go
src/cmd/compile/internal/liveness/plive.go
src/cmd/compile/internal/ssa/deadstore.go
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/lower.go
src/cmd/compile/internal/ssa/nilcheck.go
src/cmd/compile/internal/ssa/numberlines.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/value.go
src/cmd/compile/internal/ssa/writebarrier.go
src/cmd/compile/internal/ssagen/ssa.go

index 2ca5d095aa91095591eff61171f5922046caf48f..abbc8c977149088c091a0e86693fd49a5ca8ec42 100644 (file)
@@ -249,7 +249,7 @@ func (lv *argLiveness) valueEffect(v *ssa.Value, live bitvec.BitVec) bool {
 func mayFault(v *ssa.Value) bool {
        switch v.Op {
        case ssa.OpLoadReg, ssa.OpStoreReg, ssa.OpCopy, ssa.OpPhi,
-               ssa.OpVarDef, ssa.OpVarKill, ssa.OpVarLive, ssa.OpKeepAlive,
+               ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive,
                ssa.OpSelect0, ssa.OpSelect1, ssa.OpSelectN, ssa.OpMakeResult,
                ssa.OpConvert, ssa.OpInlMark, ssa.OpGetG:
                return false
index 93f49fad454cb0c8107c964a7f4823e3a80ddfff..1a2d3a45c99c8a5c93003b754fa24c7a43cadaf4 100644 (file)
@@ -80,15 +80,6 @@ import (
 // the liveness analysis work on single-word values as well, although
 // there are complications around interface values, slices, and strings,
 // all of which cannot be treated as individual words.
-//
-// OpVarKill is the opposite of OpVarDef: it marks a value as no longer needed,
-// even if its address has been taken. That is, an OpVarKill annotation asserts
-// that its argument is certainly dead, for use when the liveness analysis
-// would not otherwise be able to deduce that fact.
-
-// TODO: get rid of OpVarKill here. It's useful for stack frame allocation
-// so the compiler can allocate two temps to the same location. Here it's now
-// useless, since the implementation of stack objects.
 
 // blockEffects summarizes the liveness effects on an SSA block.
 type blockEffects struct {
@@ -269,7 +260,7 @@ func (lv *liveness) valueEffects(v *ssa.Value) (int32, liveEffect) {
        // 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:
+       case ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive:
                if !n.Used() {
                        return -1, 0
                }
@@ -334,7 +325,7 @@ func affectedVar(v *ssa.Value) (*ir.Name, ssa.SymEffect) {
 
        case ssa.OpVarLive:
                return v.Aux.(*ir.Name), ssa.SymRead
-       case ssa.OpVarDef, ssa.OpVarKill:
+       case ssa.OpVarDef:
                return v.Aux.(*ir.Name), ssa.SymWrite
        case ssa.OpKeepAlive:
                n, _ := ssa.AutoVar(v.Args[0])
index d694133ec3bb8dc17d67e61770026a585846bb62..b0e4e2bb0926f0fc913099ef81916996c23436da 100644 (file)
@@ -39,7 +39,7 @@ func dse(f *Func) {
                                for _, a := range v.Args {
                                        if a.Block == b && a.Type.IsMemory() {
                                                storeUse.add(a.ID)
-                                               if v.Op != OpStore && v.Op != OpZero && v.Op != OpVarDef && v.Op != OpVarKill {
+                                               if v.Op != OpStore && v.Op != OpZero && v.Op != OpVarDef {
                                                        // CALL, DUFFCOPY, etc. are both
                                                        // reads and writes.
                                                        loadUse.add(a.ID)
@@ -156,7 +156,7 @@ func elimDeadAutosGeneric(f *Func) {
                                changed = true
                        }
                        return
-               case OpVarDef, OpVarKill:
+               case OpVarDef:
                        // v should be eliminated if we eliminate the auto.
                        n, ok := v.Aux.(*ir.Name)
                        if !ok || n.Class != ir.PAUTO {
index 4ed016f4ad03f23754ba9a3252ee67c0e025c44f..3eaba3a2385abd87481457a5d8cf4861144c4b62 100644 (file)
@@ -613,7 +613,7 @@ func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingLevel int, stackOffset func(
        // This would probably be better as an output from stackframe.
        for _, b := range f.Blocks {
                for _, v := range b.Values {
-                       if v.Op == OpVarDef || v.Op == OpVarKill {
+                       if v.Op == OpVarDef {
                                n := v.Aux.(*ir.Name)
                                if ir.IsSynthetic(n) {
                                        continue
@@ -1080,7 +1080,7 @@ func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register)
        }
 
        switch {
-       case v.Op == OpVarDef, v.Op == OpVarKill:
+       case v.Op == OpVarDef:
                n := v.Aux.(*ir.Name)
                if ir.IsSynthetic(n) {
                        break
index e04b7db6e7ca36ec89eac6cddc014c307780ab1d..da386b9dffbabfb7be00946d832b5168b89d4a14 100644 (file)
@@ -528,7 +528,6 @@ var genericOps = []opData{
        {name: "Unknown"},
 
        {name: "VarDef", argLength: 1, aux: "Sym", typ: "Mem", symEffect: "None", zeroWidth: true}, // aux is a *gc.Node of a variable that is about to be initialized.  arg0=mem, returns mem
-       {name: "VarKill", argLength: 1, aux: "Sym", symEffect: "None"},                             // aux is a *gc.Node of a variable that is known to be dead.  arg0=mem, returns mem
        // TODO: what's the difference between VarLive and KeepAlive?
        {name: "VarLive", argLength: 1, aux: "Sym", symEffect: "Read", zeroWidth: true}, // aux is a *gc.Node of a variable that must be kept live.  arg0=mem, returns mem
        {name: "KeepAlive", argLength: 2, typ: "Mem", zeroWidth: true},                  // arg[0] is a value that must be kept alive until this mark.  arg[1]=mem, returns mem
index 5760c356015f165b243f3d2c29a303232e1a4721..fb4b7484136a8745ec518ee4abd7d85dd20eda3f 100644 (file)
@@ -21,7 +21,7 @@ func checkLower(f *Func) {
                                continue // lowered
                        }
                        switch v.Op {
-                       case OpSP, OpSB, OpInitMem, OpArg, OpArgIntReg, OpArgFloatReg, OpPhi, OpVarDef, OpVarKill, OpVarLive, OpKeepAlive, OpSelect0, OpSelect1, OpSelectN, OpConvert, OpInlMark:
+                       case OpSP, OpSB, OpInitMem, OpArg, OpArgIntReg, OpArgFloatReg, OpPhi, OpVarDef, OpVarLive, OpKeepAlive, OpSelect0, OpSelect1, OpSelectN, OpConvert, OpInlMark:
                                continue // ok not to lower
                        case OpMakeResult:
                                if b.Controls[0] == v {
index 14f511a5f1cfc6545f35a8f414b2a62b1cdae35d..521cdfd7ae74f76932afa44f11759e4d0b2e476d 100644 (file)
@@ -236,7 +236,7 @@ func nilcheckelim2(f *Func) {
                                continue
                        }
                        if v.Type.IsMemory() || v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() {
-                               if v.Op == OpVarKill || v.Op == OpVarLive || (v.Op == OpVarDef && !v.Aux.(*ir.Name).Type().HasPointers()) {
+                               if v.Op == OpVarLive || (v.Op == OpVarDef && !v.Aux.(*ir.Name).Type().HasPointers()) {
                                        // These ops don't really change memory.
                                        continue
                                        // Note: OpVarDef requires that the defined variable not have pointers.
index 9d6aeca9c0dc019b6cbafc7bd05f61b51383a036..4cbc4919f497b178f86cd32391d537eef897406c 100644 (file)
@@ -62,7 +62,7 @@ func nextGoodStatementIndex(v *Value, i int, b *Block) int {
 // statement boundary.
 func notStmtBoundary(op Op) bool {
        switch op {
-       case OpCopy, OpPhi, OpVarKill, OpVarDef, OpVarLive, OpUnknown, OpFwdRef, OpArg, OpArgIntReg, OpArgFloatReg:
+       case OpCopy, OpPhi, OpVarDef, OpVarLive, OpUnknown, OpFwdRef, OpArg, OpArgIntReg, OpArgFloatReg:
                return true
        }
        return false
index efda41f69cc92dce7b779402683b92b2e76f1bab..84b4763ff5407759a5a9ea5ba7bb223a8b2158eb 100644 (file)
@@ -3088,7 +3088,6 @@ const (
        OpFwdRef
        OpUnknown
        OpVarDef
-       OpVarKill
        OpVarLive
        OpKeepAlive
        OpInlMark
@@ -39144,13 +39143,6 @@ var opcodeTable = [...]opInfo{
                symEffect: SymNone,
                generic:   true,
        },
-       {
-               name:      "VarKill",
-               auxType:   auxSym,
-               argLen:    1,
-               symEffect: SymNone,
-               generic:   true,
-       },
        {
                name:      "VarLive",
                auxType:   auxSym,
index 8f125cef99357dc61ebdc047988d9b089a091f1e..9f2f4689e745e256430a35f296124a3c2b92235a 100644 (file)
@@ -520,7 +520,7 @@ func (v *Value) LackingPos() bool {
        // The exact definition of LackingPos is somewhat heuristically defined and may change
        // in the future, for example if some of these operations are generated more carefully
        // with respect to their source position.
-       return v.Op == OpVarDef || v.Op == OpVarKill || v.Op == OpVarLive || v.Op == OpPhi ||
+       return v.Op == OpVarDef || v.Op == OpVarLive || v.Op == OpPhi ||
                (v.Op == OpFwdRef || v.Op == OpCopy) && v.Type == types.TypeMem
 }
 
index d32669bdbcac90c6e2df740d4aa267e67f9a517c..cb8c0a5e0eb7b4eef21f6c65a1426fd73be96a69 100644 (file)
@@ -163,7 +163,7 @@ func writebarrier(f *Func) {
                                        last = w
                                        end = i + 1
                                }
-                       case OpVarDef, OpVarLive, OpVarKill:
+                       case OpVarDef, OpVarLive:
                                continue
                        default:
                                if last == nil {
@@ -279,7 +279,7 @@ func writebarrier(f *Func) {
                                fn = typedmemclr
                                typ = reflectdata.TypeLinksym(w.Aux.(*types.Type))
                                nWBops--
-                       case OpVarDef, OpVarLive, OpVarKill:
+                       case OpVarDef, OpVarLive:
                        }
 
                        // then block: emit write barrier call
@@ -301,7 +301,7 @@ func writebarrier(f *Func) {
                                }
                                // Note that we set up a writebarrier function call.
                                f.fe.SetWBPos(pos)
-                       case OpVarDef, OpVarLive, OpVarKill:
+                       case OpVarDef, OpVarLive:
                                memThen = bThen.NewValue1A(pos, w.Op, types.TypeMem, w.Aux, memThen)
                        }
 
@@ -315,7 +315,7 @@ func writebarrier(f *Func) {
                        case OpZeroWB:
                                memElse = bElse.NewValue2I(pos, OpZero, types.TypeMem, w.AuxInt, ptr, memElse)
                                memElse.Aux = w.Aux
-                       case OpVarDef, OpVarLive, OpVarKill:
+                       case OpVarDef, OpVarLive:
                                memElse = bElse.NewValue1A(pos, w.Op, types.TypeMem, w.Aux, memElse)
                        }
                }
index 847a5133c92ba78fed883462b49fa45a3f0b3cc3..e5fe646eaf746b5140957c7c0a2b79b45757eb5e 100644 (file)
@@ -1470,9 +1470,6 @@ func (s *state) stmt(n ir.Node) {
                                s.Fatalf("dottype of non-load")
                        }
                        mem := s.mem()
-                       if mem.Op == ssa.OpVarKill {
-                               mem = mem.Args[0]
-                       }
                        if res.Args[1] != mem {
                                s.Fatalf("memory no longer live from 2-result dottype load")
                        }
@@ -6947,7 +6944,7 @@ func genssa(f *ssa.Func, pp *objw.Progs) {
                        case ssa.OpGetG:
                                // nothing to do when there's a g register,
                                // and checkLower complains if there's not
-                       case ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive, ssa.OpVarKill:
+                       case ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive:
                                // nothing to do; already used by liveness
                        case ssa.OpPhi:
                                CheckLoweredPhi(v)