1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:41:36 -07:00

[dev.regabi] cmd/compile: remove original addrtaken bit

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>
This commit is contained in:
Keith Randall 2020-11-28 12:37:55 -08:00
parent 0523d525ae
commit 0620c674dd
5 changed files with 1 additions and 24 deletions

View 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)

View 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 {

View 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 {

View 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)
}

View 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)))
}