aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2025-08-07 22:57:58 +0700
committerGopher Robot <gobot@golang.org>2025-08-08 14:22:23 -0700
commit317be4cfeb7fc92bd7d5569aa8dff8f568e02f78 (patch)
treeaf7ab635551a7670a748ade11eaa78961ffc68ca /src/cmd/compile/internal
parentbce5601cbbb1a3a33ecdb13b796033e44931a3da (diff)
downloadgo-317be4cfeb7fc92bd7d5569aa8dff8f568e02f78.tar.xz
cmd/compile/internal/staticinit: remove deadcode
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>
Diffstat (limited to 'src/cmd/compile/internal')
-rw-r--r--src/cmd/compile/internal/staticinit/sched.go39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/cmd/compile/internal/staticinit/sched.go b/src/cmd/compile/internal/staticinit/sched.go
index ce2e921771..5e39bb512f 100644
--- a/src/cmd/compile/internal/staticinit/sched.go
+++ b/src/cmd/compile/internal/staticinit/sched.go
@@ -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
}