Passes toolstash -cmp.
Updates #15756
Change-Id: Ia071dbbd7f2ee0f8433d8c37af4f7b588016244e
Reviewed-on: https://go-review.googlesource.com/38231
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
var stkptrsize int64 // prefix of stack containing pointers
-var hasdefer bool // flag that curfn has defer statement
-
var Curfn *Node
var Widthptr int
return
}
- hasdefer = false
walk(fn)
if nerrors != 0 {
return
// pointers to copy values back to the stack).
// TODO: if the output parameter is heap-allocated, then we
// don't need to keep the stack copy live?
- if hasdefer {
+ if lv.fn.Func.HasDefer() {
for i, n := range lv.vars {
if n.Class == PPARAMOUT {
if n.IsOutputParamHeapAddr() {
s.pushLine(fn.Pos)
defer s.popLine()
+ s.hasdefer = fn.Func.HasDefer()
if fn.Func.Pragma&CgoUnsafeArgs != 0 {
s.cgoUnsafeArgs = true
}
placeholder *ssa.Value
cgoUnsafeArgs bool
+ hasdefer bool // whether the function contains a defer statement
}
type funcLine struct {
// It returns a BlockRet block that ends the control flow. Its control value
// will be set to the final memory state.
func (s *state) exit() *ssa.Block {
- if hasdefer {
+ if s.hasdefer {
s.rtcall(Deferreturn, true, nil)
}
case PEXTERN:
return false
case PPARAMOUT:
- if hasdefer {
+ if s.hasdefer {
// TODO: handle this case? Named return values must be
// in memory so that the deferred function can see them.
// Maybe do: if !strings.HasPrefix(n.String(), "~") { return false }
funcReflectMethod // function calls reflect.Type.Method or MethodByName
funcIsHiddenClosure
funcNoFramePointer // Must not use a frame pointer for this function
+ funcHasDefer // contains a defer statement
)
func (f *Func) Dupok() bool { return f.flags&funcDupok != 0 }
func (f *Func) ReflectMethod() bool { return f.flags&funcReflectMethod != 0 }
func (f *Func) IsHiddenClosure() bool { return f.flags&funcIsHiddenClosure != 0 }
func (f *Func) NoFramePointer() bool { return f.flags&funcNoFramePointer != 0 }
+func (f *Func) HasDefer() bool { return f.flags&funcHasDefer != 0 }
func (f *Func) SetDupok(b bool) { f.flags.set(funcDupok, b) }
func (f *Func) SetWrapper(b bool) { f.flags.set(funcWrapper, b) }
func (f *Func) SetReflectMethod(b bool) { f.flags.set(funcReflectMethod, b) }
func (f *Func) SetIsHiddenClosure(b bool) { f.flags.set(funcIsHiddenClosure, b) }
func (f *Func) SetNoFramePointer(b bool) { f.flags.set(funcNoFramePointer, b) }
+func (f *Func) SetHasDefer(b bool) { f.flags.set(funcHasDefer, b) }
type Op uint8
n.Right = walkstmt(n.Right)
case ODEFER:
- hasdefer = true
+ Curfn.Func.SetHasDefer(true)
switch n.Left.Op {
case OPRINT, OPRINTN:
n.Left = walkprintfunc(n.Left, &n.Ninit)