@@ -622,12 +622,6 @@ func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.Inli
622
622
// INLCALL-ReturnVars
623
623
// . NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13
624
624
//
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
- //
631
625
// If the init values are side-effect-free and each either only
632
626
// appears once in the function body or is safely repeatable,
633
627
// 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
647
641
// is the most important case for us to get right.
648
642
649
643
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 {
656
645
return false
657
646
}
647
+ as2init := init [0 ].(* ir.AssignListStmt )
648
+
658
649
if len (call .Body ) != 2 || call .Body [0 ].Op () != ir .OBLOCK || call .Body [1 ].Op () != ir .OLABEL {
659
650
return false
660
651
}
661
652
label := call .Body [1 ].(* ir.LabelStmt ).Label
662
653
block := call .Body [0 ].(* ir.BlockStmt )
663
654
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 {
673
660
return false
674
661
}
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 )
683
664
if len (as2body .Lhs ) != 1 || as2body .Lhs [0 ] != dcl .X {
684
665
return false
685
666
}
0 commit comments