]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/staticinit: remove deadcode
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 7 Aug 2025 15:57:58 +0000 (22:57 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 8 Aug 2025 21:22:23 +0000 (14:22 -0700)
The staticAssignInlinedCall function contains code for handling
non-Unified IR. As Unified IR is now the sole format for the frontend,
this code is obsolete and can be removed.

Change-Id: Iac93a9b59ec6d639851e1b17ba1f75563d8bcda5
Reviewed-on: https://go-review.googlesource.com/c/go/+/694075
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/staticinit/sched.go

index ce2e921771ed941a05a3780ea6af72f3bb49f2fc..5e39bb512f45f4cfe251ede6b244c4d665eb4605 100644 (file)
@@ -622,12 +622,6 @@ func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.Inli
        //      INLCALL-ReturnVars
        //      .   NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13
        //
-       // In non-unified IR, the tree is slightly different:
-       //  - if there are no arguments to the inlined function,
-       //    the INLCALL-init omits the AS2.
-       //  - the DCL inside BLOCK is on the AS2's init list,
-       //    not its own statement in the top level of the BLOCK.
-       //
        // If the init values are side-effect-free and each either only
        // appears once in the function body or is safely repeatable,
        // then we inline the value expressions into the return argument
@@ -647,39 +641,26 @@ func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.Inli
        // is the most important case for us to get right.
 
        init := call.Init()
-       var as2init *ir.AssignListStmt
-       if len(init) == 2 && init[0].Op() == ir.OAS2 && init[1].Op() == ir.OINLMARK {
-               as2init = init[0].(*ir.AssignListStmt)
-       } else if len(init) == 1 && init[0].Op() == ir.OINLMARK {
-               as2init = new(ir.AssignListStmt)
-       } else {
+       if len(init) != 2 || init[0].Op() != ir.OAS2 || init[1].Op() != ir.OINLMARK {
                return false
        }
+       as2init := init[0].(*ir.AssignListStmt)
+
        if len(call.Body) != 2 || call.Body[0].Op() != ir.OBLOCK || call.Body[1].Op() != ir.OLABEL {
                return false
        }
        label := call.Body[1].(*ir.LabelStmt).Label
        block := call.Body[0].(*ir.BlockStmt)
        list := block.List
-       var dcl *ir.Decl
-       if len(list) == 3 && list[0].Op() == ir.ODCL {
-               dcl = list[0].(*ir.Decl)
-               list = list[1:]
-       }
-       if len(list) != 2 ||
-               list[0].Op() != ir.OAS2 ||
-               list[1].Op() != ir.OGOTO ||
-               list[1].(*ir.BranchStmt).Label != label {
+       if len(list) != 3 ||
+               list[0].Op() != ir.ODCL ||
+               list[1].Op() != ir.OAS2 ||
+               list[2].Op() != ir.OGOTO ||
+               list[2].(*ir.BranchStmt).Label != label {
                return false
        }
-       as2body := list[0].(*ir.AssignListStmt)
-       if dcl == nil {
-               ainit := as2body.Init()
-               if len(ainit) != 1 || ainit[0].Op() != ir.ODCL {
-                       return false
-               }
-               dcl = ainit[0].(*ir.Decl)
-       }
+       dcl := list[0].(*ir.Decl)
+       as2body := list[1].(*ir.AssignListStmt)
        if len(as2body.Lhs) != 1 || as2body.Lhs[0] != dcl.X {
                return false
        }