Skip to content

Commit 317be4c

Browse files
cuonglmgopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent bce5601 commit 317be4c

File tree

1 file changed

+10
-29
lines changed
  • src/cmd/compile/internal/staticinit

1 file changed

+10
-29
lines changed

src/cmd/compile/internal/staticinit/sched.go

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,6 @@ func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.Inli
622622
// INLCALL-ReturnVars
623623
// . NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13
624624
//
625-
// In non-unified IR, the tree is slightly different:
626-
// - if there are no arguments to the inlined function,
627-
// the INLCALL-init omits the AS2.
628-
// - the DCL inside BLOCK is on the AS2's init list,
629-
// not its own statement in the top level of the BLOCK.
630-
//
631625
// If the init values are side-effect-free and each either only
632626
// appears once in the function body or is safely repeatable,
633627
// 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
647641
// is the most important case for us to get right.
648642

649643
init := call.Init()
650-
var as2init *ir.AssignListStmt
651-
if len(init) == 2 && init[0].Op() == ir.OAS2 && init[1].Op() == ir.OINLMARK {
652-
as2init = init[0].(*ir.AssignListStmt)
653-
} else if len(init) == 1 && init[0].Op() == ir.OINLMARK {
654-
as2init = new(ir.AssignListStmt)
655-
} else {
644+
if len(init) != 2 || init[0].Op() != ir.OAS2 || init[1].Op() != ir.OINLMARK {
656645
return false
657646
}
647+
as2init := init[0].(*ir.AssignListStmt)
648+
658649
if len(call.Body) != 2 || call.Body[0].Op() != ir.OBLOCK || call.Body[1].Op() != ir.OLABEL {
659650
return false
660651
}
661652
label := call.Body[1].(*ir.LabelStmt).Label
662653
block := call.Body[0].(*ir.BlockStmt)
663654
list := block.List
664-
var dcl *ir.Decl
665-
if len(list) == 3 && list[0].Op() == ir.ODCL {
666-
dcl = list[0].(*ir.Decl)
667-
list = list[1:]
668-
}
669-
if len(list) != 2 ||
670-
list[0].Op() != ir.OAS2 ||
671-
list[1].Op() != ir.OGOTO ||
672-
list[1].(*ir.BranchStmt).Label != label {
655+
if len(list) != 3 ||
656+
list[0].Op() != ir.ODCL ||
657+
list[1].Op() != ir.OAS2 ||
658+
list[2].Op() != ir.OGOTO ||
659+
list[2].(*ir.BranchStmt).Label != label {
673660
return false
674661
}
675-
as2body := list[0].(*ir.AssignListStmt)
676-
if dcl == nil {
677-
ainit := as2body.Init()
678-
if len(ainit) != 1 || ainit[0].Op() != ir.ODCL {
679-
return false
680-
}
681-
dcl = ainit[0].(*ir.Decl)
682-
}
662+
dcl := list[0].(*ir.Decl)
663+
as2body := list[1].(*ir.AssignListStmt)
683664
if len(as2body.Lhs) != 1 || as2body.Lhs[0] != dcl.X {
684665
return false
685666
}

0 commit comments

Comments
 (0)