]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/inline/inlheur: remove ConstExpr assumption
authorMatthew Dempsky <mdempsky@google.com>
Wed, 6 Sep 2023 22:43:12 +0000 (15:43 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 7 Sep 2023 15:10:40 +0000 (15:10 +0000)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/compile/internal/inline/inlheur/analyze_func_returns.go

index ca91b2784ed86bad8bc31886e900326524623bdf..d19c3793a27d39f3d5e75201996dc4b59acc561c 100644 (file)
@@ -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