}
// Populate closure variables.
- if !fn.ClosureCalled() {
+ if fn.Needctxt() {
clo := s.entryNewValue0(ssa.OpGetClosurePtr, s.f.Config.Types.BytePtr)
offset := int64(types.PtrSize) // PtrSize to skip past function entry PC field
for _, n := range fn.ClosureVars {
if len(callArgs) == 0 && call.Op() == ir.OCALLFUNC && callX.Type().NumResults() == 0 {
if callX.Op() == ir.OCLOSURE {
clo := callX.(*ir.ClosureExpr)
- clo.Func.SetClosureCalled(false)
clo.IsGoWrap = true
}
return
// Deal with "defer returnsafunc()(x, y)" (for
// example) by copying the callee expression.
fnExpr = mkArgCopy(callX)
- if callX.Op() == ir.OCLOSURE {
- // For "defer func(...)", in addition to copying the
- // closure into a temp, mark it as no longer directly
- // called.
- callX.(*ir.ClosureExpr).Func.SetClosureCalled(false)
- }
}
}
topcall := ir.NewCallExpr(n.Pos(), ir.OCALL, clo, nil)
typecheck.Call(topcall)
- fn.SetClosureCalled(false)
-
// Finally, point the defer statement at the newly generated call.
n.Call = topcall
}