From: Matthew Dempsky Date: Wed, 6 Sep 2023 22:43:12 +0000 (-0700) Subject: cmd/compile/internal/inline/inlheur: remove ConstExpr assumption X-Git-Tag: go1.22rc1~969 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0725410df5221fc6552298eec41548b0ab02ac6e;p=gostls13.git cmd/compile/internal/inline/inlheur: remove ConstExpr assumption OLITERAL isn't always ConstExpr. It can also be BasicLit or Name. Change-Id: I44d595830f9e206eccf6fb37bd47ddf957db0866 Reviewed-on: https://go-review.googlesource.com/c/go/+/526277 LUCI-TryBot-Result: Go LUCI Auto-Submit: Matthew Dempsky Reviewed-by: Cuong Manh Le Reviewed-by: Than McIntosh --- diff --git a/src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go b/src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go index ca91b2784e..d19c3793a2 100644 --- a/src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go +++ b/src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go @@ -222,14 +222,13 @@ func isAllocatedMem(n ir.Node) bool { func isLiteral(n ir.Node) (constant.Value, bool) { sv := ir.StaticValue(n) - if sv.Op() == ir.ONIL { + switch sv.Op() { + case ir.ONIL: return nil, true + case ir.OLITERAL: + return sv.Val(), true } - if sv.Op() != ir.OLITERAL { - return nil, false - } - ce := sv.(*ir.ConstExpr) - return ce.Val(), true + return nil, false } // isSameLiteral checks to see if 'v1' and 'v2' correspond to the same