]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: remove original addrtaken bit
authorKeith Randall <khr@golang.org>
Sat, 28 Nov 2020 20:37:55 +0000 (12:37 -0800)
committerKeith Randall <khr@golang.org>
Tue, 29 Dec 2020 18:04:37 +0000 (18:04 +0000)
Switch the source of truth to the new addrtaken bit. Remove the old one.

Change-Id: Ie53679ab14cfcd34b55e912e7ecb962a22db7db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/275696
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/walk/order.go

index 7324369ced9edfb2c1a651192af53eb09b58b769..8f3a4b4d8cc09d19cbfd458d5d3754ae85651e69 100644 (file)
@@ -1012,7 +1012,6 @@ func inlvar(var_ ir.Node) ir.Node {
        n.Class_ = ir.PAUTO
        n.SetUsed(true)
        n.Curfn = ir.CurFunc // the calling function, not the called one
-       n.SetAddrtaken(var_.Name().Addrtaken())
        n.SetAddrtaken2(var_.Name().Addrtaken())
 
        ir.CurFunc.Dcl = append(ir.CurFunc.Dcl, n)
index 8b1084deeb3917d9c4c75c6370b7e9f0dbdca151..6e41fd650bc25e9a7f8619f356f3c7e73cd0f7ce 100644 (file)
@@ -285,7 +285,7 @@ func (n *Name) Used() bool                  { return n.flags&nameUsed != 0 }
 func (n *Name) IsClosureVar() bool          { return n.flags&nameIsClosureVar != 0 }
 func (n *Name) IsOutputParamHeapAddr() bool { return n.flags&nameIsOutputParamHeapAddr != 0 }
 func (n *Name) Assigned() bool              { return n.flags&nameAssigned != 0 }
-func (n *Name) Addrtaken() bool             { return n.checkAddrtaken() && n.flags&nameAddrtaken != 0 }
+func (n *Name) Addrtaken() bool             { return n.flags&nameAddrtaken2 != 0 }
 func (n *Name) InlFormal() bool             { return n.flags&nameInlFormal != 0 }
 func (n *Name) InlLocal() bool              { return n.flags&nameInlLocal != 0 }
 func (n *Name) OpenDeferSlot() bool         { return n.flags&nameOpenDeferSlot != 0 }
@@ -300,24 +300,12 @@ func (n *Name) SetUsed(b bool)                  { n.flags.set(nameUsed, b) }
 func (n *Name) SetIsClosureVar(b bool)          { n.flags.set(nameIsClosureVar, b) }
 func (n *Name) SetIsOutputParamHeapAddr(b bool) { n.flags.set(nameIsOutputParamHeapAddr, b) }
 func (n *Name) SetAssigned(b bool)              { n.flags.set(nameAssigned, b) }
-func (n *Name) SetAddrtaken(b bool)             { n.flags.set(nameAddrtaken, b) }
 func (n *Name) SetAddrtaken2(b bool)            { n.flags.set(nameAddrtaken2, b) }
 func (n *Name) SetInlFormal(b bool)             { n.flags.set(nameInlFormal, b) }
 func (n *Name) SetInlLocal(b bool)              { n.flags.set(nameInlLocal, b) }
 func (n *Name) SetOpenDeferSlot(b bool)         { n.flags.set(nameOpenDeferSlot, b) }
 func (n *Name) SetLibfuzzerExtraCounter(b bool) { n.flags.set(nameLibfuzzerExtraCounter, b) }
 
-func (n *Name) checkAddrtaken() bool {
-       // The two different ways of computing addrtaken bits might diverge during computation,
-       // but any time we look at them, they should be identical.
-       x := n.flags&nameAddrtaken != 0
-       y := n.flags&nameAddrtaken2 != 0
-       if x != y {
-               panic("inconsistent addrtaken")
-       }
-       return true
-}
-
 // MarkReadonly indicates that n is an ONAME with readonly contents.
 func (n *Name) MarkReadonly() {
        if n.Op() != ONAME {
index 5752139c0b92a84cb922ee01e00557247a6080c1..12bfae67a865e6b8baa425f5157c90edfa513609 100644 (file)
@@ -35,14 +35,6 @@ func tcAddr(n *ir.AddrExpr) ir.Node {
                        if ir.Orig(r) != r {
                                base.Fatalf("found non-orig name node %v", r) // TODO(mdempsky): What does this mean?
                        }
-                       r.Name().SetAddrtaken(true)
-                       if r.Name().IsClosureVar() && !CaptureVarsComplete {
-                               // Mark the original variable as Addrtaken so that capturevars
-                               // knows not to pass it by value.
-                               // But if the capturevars phase is complete, don't touch it,
-                               // in case l.Name's containing function has not yet been compiled.
-                               r.Name().Defn.Name().SetAddrtaken(true)
-                       }
                }
                n.X = DefaultLit(n.X, nil)
                if n.X.Type() == nil {
index ce6f4027da90606f7bd8be541c773e6e414dc73b..0819380885c7a45a17b708176a79f9e7746bbde0 100644 (file)
@@ -134,7 +134,6 @@ func CaptureVars(fn *ir.Func) {
                if outermost.Class_ != ir.PPARAMOUT && !outermost.Name().Addrtaken() && !outermost.Name().Assigned() && v.Type().Width <= 128 {
                        v.SetByval(true)
                } else {
-                       outermost.Name().SetAddrtaken(true)
                        outermost.Name().SetAddrtaken2(true)
                        outer = NodAddr(outer)
                }
index 82180c113eb86c9b795175c7e8e702fcf8482020..58c1c597fcd84bd0c03bd980a467279f2bfb3557 100644 (file)
@@ -517,7 +517,6 @@ func (o *orderState) call(nn ir.Node) {
                        if arg.X.Type().IsUnsafePtr() {
                                x := o.copyExpr(arg.X)
                                arg.X = x
-                               x.Name().SetAddrtaken(true)  // ensure SSA keeps the x variable
                                x.Name().SetAddrtaken2(true) // ensure SSA keeps the x variable
                                n.Body.Append(typecheck.Stmt(ir.NewUnaryExpr(base.Pos, ir.OVARLIVE, x)))
                        }