From 6a2df450f22e25ed41f4407fb6a31b7347c85891 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 28 Jun 2023 23:15:35 +0700 Subject: [PATCH] cmd/compile: handle min/max correctly in mayCall CL 500575 changed mayCall to return "false" for min/max builtin. However, with string or float, min/max requires runtime call, so mayCall should return true instead. This's probably not a big problem, because CL 506115 makes order pass handle min/max correctly. But it's still better to do it the right way. Updates #60582 Change-Id: I9779ca62bebd0f95e52ad5fa55b9160dc35b33aa Reviewed-on: https://go-review.googlesource.com/c/go/+/506855 Auto-Submit: Cuong Manh Le Run-TryBot: Cuong Manh Le Reviewed-by: Matthew Dempsky Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot --- src/cmd/compile/internal/walk/walk.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/walk/walk.go b/src/cmd/compile/internal/walk/walk.go index 265066200c6f8..778b95d547356 100644 --- a/src/cmd/compile/internal/walk/walk.go +++ b/src/cmd/compile/internal/walk/walk.go @@ -337,10 +337,14 @@ func mayCall(n ir.Node) bool { n := n.(*ir.ConvExpr) return ssagen.Arch.SoftFloat && (isSoftFloat(n.Type()) || isSoftFloat(n.X.Type())) + case ir.OMIN, ir.OMAX: + // string or float requires runtime call, see (*ssagen.state).minmax method. + return n.Type().IsString() || n.Type().IsFloat() + case ir.OLITERAL, ir.ONIL, ir.ONAME, ir.OLINKSYMOFFSET, ir.OMETHEXPR, ir.OAND, ir.OANDNOT, ir.OLSH, ir.OOR, ir.ORSH, ir.OXOR, ir.OCOMPLEX, ir.OEFACE, ir.OADDR, ir.OBITNOT, ir.ONOT, ir.OPLUS, - ir.OCAP, ir.OIMAG, ir.OLEN, ir.OREAL, ir.OMIN, ir.OMAX, + ir.OCAP, ir.OIMAG, ir.OLEN, ir.OREAL, ir.OCONVNOP, ir.ODOT, ir.OCFUNC, ir.OIDATA, ir.OITAB, ir.OSPTR, ir.OBYTES2STRTMP, ir.OGETG, ir.OGETCALLERPC, ir.OGETCALLERSP, ir.OSLICEHEADER, ir.OSTRINGHEADER: