1
0
mirror of https://github.com/golang/go synced 2024-11-17 07:45:09 -07:00

[dev.regabi] cmd/compile: move new addrtaken bit back to the old name

Change-Id: I2732aefe95a21c23d73a907d5596fcb1626d6dd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/275697
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:55:01 -08:00
parent 0620c674dd
commit b3e1ec97fd
5 changed files with 9 additions and 10 deletions

View File

@ -1012,7 +1012,7 @@ 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.SetAddrtaken2(var_.Name().Addrtaken())
n.SetAddrtaken(var_.Name().Addrtaken())
ir.CurFunc.Dcl = append(ir.CurFunc.Dcl, n)
return n

View File

@ -38,7 +38,7 @@ type Name struct {
BuiltinOp Op // uint8
Class_ Class // uint8
pragma PragmaFlag // int16
flags bitset32
flags bitset16
sym *types.Sym
Func *Func
Offset_ int64
@ -273,7 +273,6 @@ const (
nameOpenDeferSlot // if temporary var storing info for open-coded defers
nameLibfuzzerExtraCounter // if PEXTERN should be assigned to __libfuzzer_extra_counters section
nameAlias // is type name an alias
nameAddrtaken2
)
func (n *Name) Captured() bool { return n.flags&nameCaptured != 0 }
@ -285,7 +284,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.flags&nameAddrtaken2 != 0 }
func (n *Name) Addrtaken() bool { return n.flags&nameAddrtaken != 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,7 +299,7 @@ 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) SetAddrtaken2(b bool) { n.flags.set(nameAddrtaken2, b) }
func (n *Name) SetAddrtaken(b bool) { n.flags.set(nameAddrtaken, 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) }

View File

@ -134,7 +134,7 @@ 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().SetAddrtaken2(true)
outermost.Name().SetAddrtaken(true)
outer = NodAddr(outer)
}

View File

@ -81,7 +81,7 @@ func markAddrOf(n ir.Node) ir.Node {
// Note: outervalue doesn't work correctly until n is typechecked.
n = typecheck(n, ctxExpr)
if x := ir.OuterValue(n); x.Op() == ir.ONAME {
x.Name().SetAddrtaken2(true)
x.Name().SetAddrtaken(true)
}
} else {
// Remember that we built an OADDR without computing the Addrtaken bit for
@ -106,11 +106,11 @@ func computeAddrtaken(top []ir.Node) {
ir.Visit(n, func(n ir.Node) {
if n.Op() == ir.OADDR {
if x := ir.OuterValue(n.(*ir.AddrExpr).X); x.Op() == ir.ONAME {
x.Name().SetAddrtaken2(true)
x.Name().SetAddrtaken(true)
if x.Name().IsClosureVar() {
// Mark the original variable as Addrtaken so that capturevars
// knows not to pass it by value.
x.Name().Defn.Name().SetAddrtaken2(true)
x.Name().Defn.Name().SetAddrtaken(true)
}
}
}

View File

@ -517,7 +517,7 @@ func (o *orderState) call(nn ir.Node) {
if arg.X.Type().IsUnsafePtr() {
x := o.copyExpr(arg.X)
arg.X = x
x.Name().SetAddrtaken2(true) // ensure SSA keeps the x variable
x.Name().SetAddrtaken(true) // ensure SSA keeps the x variable
n.Body.Append(typecheck.Stmt(ir.NewUnaryExpr(base.Pos, ir.OVARLIVE, x)))
}
}