@@ -509,7 +509,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
509
509
}
510
510
511
511
fn cast_box_free_arg ( & self , arg : Lvalue < ' tcx > , ptr_ty : Ty < ' tcx > ,
512
- callsite : & CallSite < ' tcx > , caller_mir : & mut Mir < ' tcx > ) -> Operand < ' tcx > {
512
+ callsite : & CallSite < ' tcx > , caller_mir : & mut Mir < ' tcx > ) -> Local {
513
513
let arg = Rvalue :: Ref (
514
514
self . tcx . types . re_erased ,
515
515
BorrowKind :: Mut ,
@@ -539,25 +539,24 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
539
539
540
540
let cast_tmp = LocalDecl :: new_temp ( ptr_ty, callsite. location . span ) ;
541
541
let cast_tmp = caller_mir. local_decls . push ( cast_tmp) ;
542
- let cast_tmp = Lvalue :: Local ( cast_tmp) ;
543
542
544
543
let cast_stmt = Statement {
545
544
source_info : callsite. location ,
546
- kind : StatementKind :: Assign ( cast_tmp . clone ( ) , raw_ptr)
545
+ kind : StatementKind :: Assign ( Lvalue :: Local ( cast_tmp ) , raw_ptr)
547
546
} ;
548
547
549
548
caller_mir[ callsite. bb ]
550
549
. statements . push ( cast_stmt) ;
551
550
552
- Operand :: Consume ( cast_tmp)
551
+ cast_tmp
553
552
}
554
553
555
554
fn make_call_args (
556
555
& self ,
557
556
args : Vec < Operand < ' tcx > > ,
558
557
callsite : & CallSite < ' tcx > ,
559
558
caller_mir : & mut Mir < ' tcx > ,
560
- ) -> Vec < Operand < ' tcx > > {
559
+ ) -> Vec < Local > {
561
560
let tcx = self . tcx ;
562
561
563
562
// There is a bit of a mismatch between the *caller* of a closure and the *callee*.
@@ -589,14 +588,15 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
589
588
let tuple = self . create_temp_if_necessary ( args. next ( ) . unwrap ( ) , callsite, caller_mir) ;
590
589
assert ! ( args. next( ) . is_none( ) ) ;
591
590
591
+ let tuple = Lvalue :: Local ( tuple) ;
592
592
let tuple_tys = if let ty:: TyTuple ( s, _) = tuple. ty ( caller_mir, tcx) . to_ty ( tcx) . sty {
593
593
s
594
594
} else {
595
595
bug ! ( "Closure arguments are not passed as a tuple" ) ;
596
596
} ;
597
597
598
598
// The `closure_ref` in our example above.
599
- let closure_ref_arg = iter:: once ( Operand :: Consume ( self_) ) ;
599
+ let closure_ref_arg = iter:: once ( self_) ;
600
600
601
601
// The `tmp0`, `tmp1`, and `tmp2` in our example abonve.
602
602
let tuple_tmp_args =
@@ -605,14 +605,13 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
605
605
let tuple_field = Operand :: Consume ( tuple. clone ( ) . field ( Field :: new ( i) , ty) ) ;
606
606
607
607
// Spill to a local to make e.g. `tmp0`.
608
- let tmp = self . create_temp_if_necessary ( tuple_field, callsite, caller_mir) ;
609
- Operand :: Consume ( tmp)
608
+ self . create_temp_if_necessary ( tuple_field, callsite, caller_mir)
610
609
} ) ;
611
610
612
611
closure_ref_arg. chain ( tuple_tmp_args) . collect ( )
613
612
} else {
614
613
args. into_iter ( )
615
- . map ( |a| Operand :: Consume ( self . create_temp_if_necessary ( a, callsite, caller_mir) ) )
614
+ . map ( |a| self . create_temp_if_necessary ( a, callsite, caller_mir) )
616
615
. collect ( )
617
616
}
618
617
}
@@ -624,14 +623,14 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
624
623
arg : Operand < ' tcx > ,
625
624
callsite : & CallSite < ' tcx > ,
626
625
caller_mir : & mut Mir < ' tcx > ,
627
- ) -> Lvalue < ' tcx > {
626
+ ) -> Local {
628
627
// FIXME: Analysis of the usage of the arguments to avoid
629
628
// unnecessary temporaries.
630
629
631
630
if let Operand :: Consume ( Lvalue :: Local ( local) ) = arg {
632
631
if caller_mir. local_kind ( local) == LocalKind :: Temp {
633
632
// Reuse the operand if it's a temporary already
634
- return Lvalue :: Local ( local) ;
633
+ return local;
635
634
}
636
635
}
637
636
@@ -643,11 +642,10 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
643
642
644
643
let arg_tmp = LocalDecl :: new_temp ( ty, callsite. location . span ) ;
645
644
let arg_tmp = caller_mir. local_decls . push ( arg_tmp) ;
646
- let arg_tmp = Lvalue :: Local ( arg_tmp) ;
647
645
648
646
let stmt = Statement {
649
647
source_info : callsite. location ,
650
- kind : StatementKind :: Assign ( arg_tmp . clone ( ) , arg) ,
648
+ kind : StatementKind :: Assign ( Lvalue :: Local ( arg_tmp ) , arg) ,
651
649
} ;
652
650
caller_mir[ callsite. bb ] . statements . push ( stmt) ;
653
651
arg_tmp
@@ -693,7 +691,7 @@ fn subst_and_normalize<'a, 'tcx: 'a>(
693
691
*/
694
692
struct Integrator < ' a , ' tcx : ' a > {
695
693
block_idx : usize ,
696
- args : & ' a [ Operand < ' tcx > ] ,
694
+ args : & ' a [ Local ] ,
697
695
local_map : IndexVec < Local , Local > ,
698
696
scope_map : IndexVec < VisibilityScope , VisibilityScope > ,
699
697
promoted_map : IndexVec < Promoted , Promoted > ,
@@ -710,15 +708,6 @@ impl<'a, 'tcx> Integrator<'a, 'tcx> {
710
708
debug ! ( "Updating target `{:?}`, new: `{:?}`" , tgt, new) ;
711
709
new
712
710
}
713
-
714
- fn arg_index ( & self , arg : Local ) -> Option < usize > {
715
- let idx = arg. index ( ) ;
716
- if idx > 0 && idx <= self . args . len ( ) {
717
- Some ( idx - 1 )
718
- } else {
719
- None
720
- }
721
- }
722
711
}
723
712
724
713
impl < ' a , ' tcx > MutVisitor < ' tcx > for Integrator < ' a , ' tcx > {
@@ -737,13 +726,8 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
737
726
}
738
727
let idx = local. index ( ) - 1 ;
739
728
if idx < self . args . len ( ) {
740
- match self . args [ idx] {
741
- Operand :: Consume ( Lvalue :: Local ( l) ) => {
742
- * local = l;
743
- return ;
744
- } ,
745
- ref op => bug ! ( "Arg operand `{:?}` is {:?}, not local" , idx, op)
746
- }
729
+ * local = self . args [ idx] ;
730
+ return ;
747
731
}
748
732
* local = self . local_map [ Local :: new ( idx - self . args . len ( ) ) ] ;
749
733
}
@@ -760,17 +744,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
760
744
}
761
745
}
762
746
763
- fn visit_operand ( & mut self , operand : & mut Operand < ' tcx > , location : Location ) {
764
- if let Operand :: Consume ( Lvalue :: Local ( arg) ) = * operand {
765
- if let Some ( idx) = self . arg_index ( arg) {
766
- let new_arg = self . args [ idx] . clone ( ) ;
767
- * operand = new_arg;
768
- return ;
769
- }
770
- }
771
- self . super_operand ( operand, location) ;
772
- }
773
-
774
747
fn visit_basic_block_data ( & mut self , block : BasicBlock , data : & mut BasicBlockData < ' tcx > ) {
775
748
self . in_cleanup_block = data. is_cleanup ;
776
749
self . super_basic_block_data ( block, data) ;
0 commit comments