For interface method values, we nil check the receiver value at the
point of evaluating the method value. Currently this is inserted by
the backend during walk, but in some cases it's useful to emit them
upfront instead.
OITAB is essentially a field selection operation, like ODOT, OIDATA,
and OSPTR.
OCHECKNIL is a statement that simply evaluates its unary operand, and
discards the result (after testing for nil).
Change-Id: I583b5170539caa9a87aec661d5c293080fd87fbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/422197
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
n := n.(*ir.BinaryExpr)
// Note: n.X is not needed because it can never point to memory that might escape.
e.expr(k, n.Y)
- case ir.OIDATA, ir.OSPTR:
+ case ir.OITAB, ir.OIDATA, ir.OSPTR:
n := n.(*ir.UnaryExpr)
e.expr(k, n.X)
case ir.OSLICE2ARRPTR:
e.block(n.Body)
e.block(n.Else)
+ case ir.OCHECKNIL:
+ n := n.(*ir.UnaryExpr)
+ e.discard(n.X)
+
case ir.OFOR, ir.OFORUNTIL:
n := n.(*ir.ForStmt)
e.loopDepth++