]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: catch another mis-used OCALLMETH in backend
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 24 Jun 2021 07:13:39 +0000 (14:13 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 25 Jun 2021 02:28:47 +0000 (02:28 +0000)
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 <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/ssagen/ssa.go

index 93847a39a3940a98efc62466926fe14a39e54df4..9212c5776e14ecfcf48f985fc2404c759ded31c4 100644 (file)
@@ -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())