]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix case in dictPass where OMETHVALUE should become ODOTMETH
authorDan Scales <danscales@google.com>
Fri, 24 Sep 2021 16:13:32 +0000 (09:13 -0700)
committerDan Scales <danscales@google.com>
Fri, 24 Sep 2021 18:11:24 +0000 (18:11 +0000)
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 <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/typecheck/subr.go

index c8ce2301217452f93f8480194dd85aef2179bf8f..cf8641d60e6806fc7728ed0f366558b617e2e80f 100644 (file)
@@ -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))
                        }
 
index 57f0dd856611a7af2d1c0cb34e0652c7202a1db4..9bd8e35a139d92765cd975d72d37eb6451c3ab8a 100644 (file)
@@ -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)
index 9233bbe6f267463a21c5fa9f28204341f77f0948..fbfe1b37204faa9d3e4d29e2fc7a0feca2c48efa 100644 (file)
@@ -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)