mirror of
https://github.com/golang/go.git
synced 2025-10-19 11:03:18 +00:00
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>
This commit is contained in:
parent
bce5601cbb
commit
317be4cfeb
1 changed files with 10 additions and 29 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue