var init ir.Nodes
e.callCommon(ks, call, &init, nil)
if len(init) != 0 {
- call.(*ir.CallExpr).PtrInit().Append(init...)
+ call.(ir.InitNode).PtrInit().Append(init...)
}
}
argumentFunc(nil, k, argp)
}
+ argumentRType := func(rtypep *ir.Node) {
+ rtype := *rtypep
+ if rtype == nil {
+ return
+ }
+ // common case: static rtype/itab argument, which can be evaluated within the wrapper instead.
+ if addr, ok := rtype.(*ir.AddrExpr); ok && addr.Op() == ir.OADDR && addr.X.Op() == ir.OLINKSYMOFFSET {
+ return
+ }
+ e.wrapExpr(rtype.Pos(), rtypep, init, call, wrapper)
+ }
+
switch call.Op() {
default:
ir.Dump("esc", call)
argument(e.heapHole(), &args[i])
}
}
+ argumentRType(&call.RType)
case ir.OCOPY:
call := call.(*ir.BinaryExpr)
copiedK = e.heapHole().deref(call, "copied slice")
}
argument(copiedK, &call.Y)
+ argumentRType(&call.RType)
case ir.OPANIC:
call := call.(*ir.UnaryExpr)
for i := range call.Args {
argument(e.discardHole(), &call.Args[i])
}
+ argumentRType(&call.RType)
case ir.OLEN, ir.OCAP, ir.OREAL, ir.OIMAG, ir.OCLOSE:
call := call.(*ir.UnaryExpr)
call := call.(*ir.BinaryExpr)
argument(ks[0], &call.X)
argument(e.discardHole(), &call.Y)
+ argumentRType(&call.RType)
}
}
--- /dev/null
+// compile
+
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type S[T comparable] struct {
+ m map[T]T
+}
+
+func (s S[T]) M1(node T) {
+ defer delete(s.m, node)
+}
+
+func (s S[T]) M2(node T) {
+ defer func() {
+ delete(s.m, node)
+ }()
+}
+
+func (s S[T]) M3(node T) {
+ defer f(s.m, node)
+}
+
+//go:noinline
+func f[T comparable](map[T]T, T) {}
+
+var _ = S[int]{}