From: Dan Scales Date: Fri, 24 Sep 2021 16:13:32 +0000 (-0700) Subject: cmd/compile: fix case in dictPass where OMETHVALUE should become ODOTMETH X-Git-Tag: go1.18beta1~1201 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=812c99f86a1b38d50c5c0b501d10b72c3b7dfb95;p=gostls13.git cmd/compile: fix case in dictPass where OMETHVALUE should become ODOTMETH When I separate out the dictionary transformations to dictPass, I missed duplicating a conditional that deals with OMETHVALUE nodes that are actually called. We create the OMETHVALUE when transforming bounds function reference (before we know whether that reference will be called), and we need to call transformDot() again to convert the OMETHVALUE to ODOTMETH if the reference is actually called (the usual case). Without this change, we leave the OMETHVALUE in, and extra *-fm are created and used unncessarily. Also, fixed a few places where we were missing ir.MarkFunc(), which sets the class of a function node properly. Change-Id: I6b02613039b16b507b44525faa2cd7031afb6982 Reviewed-on: https://go-review.googlesource.com/c/go/+/352069 Trust: Dan Scales Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index c8ce230121..cf8641d60e 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1220,6 +1220,12 @@ func (g *irgen) dictPass(info *instInfo) { op := m.(*ir.CallExpr).X.Op() if op != ir.OFUNCINST { assert(op == ir.OMETHVALUE || op == ir.OCLOSURE || op == ir.ODYNAMICDOTTYPE || op == ir.ODYNAMICDOTTYPE2) + if op == ir.OMETHVALUE { + // Redo the transformation of OXDOT, now that we + // know the method value is being called. + m.(*ir.CallExpr).X.(*ir.SelectorExpr).SetOp(ir.OXDOT) + transformDot(m.(*ir.CallExpr).X.(*ir.SelectorExpr), true) + } transformCall(m.(*ir.CallExpr)) } diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 57f0dd8566..9bd8e35a13 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -1902,6 +1902,7 @@ func substInstType(t *types.Type, baseType *types.Type, targs []*types.Type) { } else { nname = ir.NewNameAt(f.Pos, newsym) nname.SetType(t2) + ir.MarkFunc(nname) newsym.Def = nname } newfields[i] = types.NewField(f.Pos, f.Sym, t2) diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index 9233bbe6f2..fbfe1b3720 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -1269,6 +1269,7 @@ func (ts *Tsubster) typ1(t *types.Type) *types.Type { } else { nname = ir.NewNameAt(f.Pos, newsym) nname.SetType(t2) + ir.MarkFunc(nname) newsym.Def = nname } newfields[i] = types.NewField(f.Pos, f.Sym, t2)