From 0725410df5221fc6552298eec41548b0ab02ac6e Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 6 Sep 2023 15:43:12 -0700 Subject: [PATCH] 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 --- .../internal/inline/inlheur/analyze_func_returns.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 -- 2.50.0