From: Cuong Manh Le Date: Thu, 24 Jun 2021 07:13:39 +0000 (+0700) Subject: [dev.typeparams] cmd/compile: catch another mis-used OCALLMETH in backend X-Git-Tag: go1.18beta1~1818^2^2~279 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aee209c04426c50bb045e058b4f618ed306b7d62;p=gostls13.git [dev.typeparams] cmd/compile: catch another mis-used OCALLMETH in backend OCALLMETH is rewritten by walkCall to OCALLFUNC, and other places in backend have already caught it. So do the same thing in state.expr for consistency and prevent mis-use in frontend side. While at it, also remove un-used function getParam. Change-Id: I03e1ea907e0bcb05fa35fa81804c33b5c9a4d77e Reviewed-on: https://go-review.googlesource.com/c/go/+/330669 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 93847a39a3..9212c5776e 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -279,18 +279,6 @@ func regAbiForFuncType(ft *types.Func) bool { return np > 0 && strings.Contains(ft.Params.FieldType(np-1).String(), magicLastTypeName) } -// getParam returns the Field of ith param of node n (which is a -// function/method/interface call), where the receiver of a method call is -// considered as the 0th parameter. This does not include the receiver of an -// interface call. -func getParam(n *ir.CallExpr, i int) *types.Field { - t := n.X.Type() - if n.Op() == ir.OCALLMETH { - base.Fatalf("OCALLMETH missed by walkCall") - } - return t.Params().Field(i) -} - // dvarint writes a varint v to the funcdata in symbol x and returns the new offset func dvarint(x *obj.LSym, off int, v int64) int { if v < 0 || v > 1e9 { @@ -3127,10 +3115,14 @@ func (s *state) expr(n ir.Node) *ssa.Value { } fallthrough - case ir.OCALLINTER, ir.OCALLMETH: + case ir.OCALLINTER: n := n.(*ir.CallExpr) return s.callResult(n, callNormal) + case ir.OCALLMETH: + base.Fatalf("OCALLMETH missed by walkCall") + panic("unreachable") + case ir.OGETG: n := n.(*ir.CallExpr) return s.newValue1(ssa.OpGetG, n.Type(), s.mem())