@@ -515,18 +515,6 @@ pub enum TerminatorKind<'tcx> {
515
515
target : Block ,
516
516
unwind : Option < Block > ,
517
517
} ,
518
-
519
- /// Block ends with a call of a converging function
520
- Call {
521
- /// The function that’s being called
522
- func : Operand < ' tcx > ,
523
- /// Arguments the function is called with
524
- args : Vec < Operand < ' tcx > > ,
525
- /// Destination for the return value. If some, the call is converging.
526
- destination : Option < ( Lvalue < ' tcx > , Block ) > ,
527
- /// Cleanups to be done if the call unwinds.
528
- cleanup : Option < Block >
529
- } ,
530
518
}
531
519
532
520
impl < ' tcx > Terminator < ' tcx > {
@@ -559,11 +547,6 @@ impl<'tcx> TerminatorKind<'tcx> {
559
547
Resume => ( & [ ] ) . into_cow ( ) ,
560
548
Return => ( & [ ] ) . into_cow ( ) ,
561
549
Unreachable => ( & [ ] ) . into_cow ( ) ,
562
- Call { destination : Some ( ( _, t) ) , cleanup : Some ( c) , .. } => vec ! [ t, c] . into_cow ( ) ,
563
- Call { destination : Some ( ( _, ref t) ) , cleanup : None , .. } =>
564
- slice:: ref_slice ( t) . into_cow ( ) ,
565
- Call { destination : None , cleanup : Some ( ref c) , .. } => slice:: ref_slice ( c) . into_cow ( ) ,
566
- Call { destination : None , cleanup : None , .. } => ( & [ ] ) . into_cow ( ) ,
567
550
DropAndReplace { target, unwind : Some ( unwind) , .. } |
568
551
Drop { target, unwind : Some ( unwind) , .. } => {
569
552
vec ! [ target, unwind] . into_cow ( )
@@ -585,10 +568,6 @@ impl<'tcx> TerminatorKind<'tcx> {
585
568
Resume => Vec :: new ( ) ,
586
569
Return => Vec :: new ( ) ,
587
570
Unreachable => Vec :: new ( ) ,
588
- Call { destination : Some ( ( _, ref mut t) ) , cleanup : Some ( ref mut c) , .. } => vec ! [ t, c] ,
589
- Call { destination : Some ( ( _, ref mut t) ) , cleanup : None , .. } => vec ! [ t] ,
590
- Call { destination : None , cleanup : Some ( ref mut c) , .. } => vec ! [ c] ,
591
- Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
592
571
DropAndReplace { ref mut target, unwind : Some ( ref mut unwind) , .. } |
593
572
Drop { ref mut target, unwind : Some ( ref mut unwind) , .. } => vec ! [ target, unwind] ,
594
573
DropAndReplace { ref mut target, unwind : None , .. } |
@@ -663,19 +642,6 @@ impl<'tcx> TerminatorKind<'tcx> {
663
642
Drop { ref location, .. } => write ! ( fmt, "drop({:?})" , location) ,
664
643
DropAndReplace { ref location, ref value, .. } =>
665
644
write ! ( fmt, "replace({:?} <- {:?})" , location, value) ,
666
- Call { ref func, ref args, ref destination, .. } => {
667
- if let Some ( ( ref destination, _) ) = * destination {
668
- write ! ( fmt, "{:?} = " , destination) ?;
669
- }
670
- write ! ( fmt, "{:?}(" , func) ?;
671
- for ( index, arg) in args. iter ( ) . enumerate ( ) {
672
- if index > 0 {
673
- write ! ( fmt, ", " ) ?;
674
- }
675
- write ! ( fmt, "{:?}" , arg) ?;
676
- }
677
- write ! ( fmt, ")" )
678
- }
679
645
}
680
646
}
681
647
@@ -695,11 +661,6 @@ impl<'tcx> TerminatorKind<'tcx> {
695
661
. chain ( iter:: once ( String :: from ( "otherwise" ) . into ( ) ) )
696
662
. collect ( )
697
663
}
698
- Call { destination : Some ( _) , cleanup : Some ( _) , .. } =>
699
- vec ! [ "return" . into_cow( ) , "unwind" . into_cow( ) ] ,
700
- Call { destination : Some ( _) , cleanup : None , .. } => vec ! [ "return" . into_cow( ) ] ,
701
- Call { destination : None , cleanup : Some ( _) , .. } => vec ! [ "unwind" . into_cow( ) ] ,
702
- Call { destination : None , cleanup : None , .. } => vec ! [ ] ,
703
664
DropAndReplace { unwind : None , .. } |
704
665
Drop { unwind : None , .. } => vec ! [ "return" . into_cow( ) ] ,
705
666
DropAndReplace { unwind : Some ( _) , .. } |
@@ -737,19 +698,39 @@ impl<'tcx> Statement<'tcx> {
737
698
738
699
pub fn cleanup_target ( & self ) -> Option < Block > {
739
700
match self . kind {
740
- StatementKind :: Assert { cleanup : Some ( unwind) , .. } => {
741
- Some ( unwind)
701
+ StatementKind :: Assign ( ..) |
702
+ StatementKind :: SetDiscriminant { .. } |
703
+ StatementKind :: StorageLive ( ..) |
704
+ StatementKind :: StorageDead ( ..) |
705
+ StatementKind :: InlineAsm { .. } |
706
+ StatementKind :: Nop => None ,
707
+ StatementKind :: Assert { cleanup : unwind, .. } |
708
+ StatementKind :: Call { cleanup : unwind, .. } => {
709
+ if let Some ( unwind) = unwind {
710
+ Some ( unwind)
711
+ } else {
712
+ None
713
+ }
742
714
}
743
- _ => None
744
715
}
745
716
}
746
717
747
718
pub fn cleanup_target_mut ( & mut self ) -> Option < & mut Block > {
748
719
match self . kind {
749
- StatementKind :: Assert { cleanup : Some ( ref mut unwind) , .. } => {
750
- Some ( unwind)
720
+ StatementKind :: Assign ( ..) |
721
+ StatementKind :: SetDiscriminant { .. } |
722
+ StatementKind :: StorageLive ( ..) |
723
+ StatementKind :: StorageDead ( ..) |
724
+ StatementKind :: InlineAsm { .. } |
725
+ StatementKind :: Nop => None ,
726
+ StatementKind :: Assert { cleanup : ref mut unwind, .. } |
727
+ StatementKind :: Call { cleanup : ref mut unwind, .. } => {
728
+ if let Some ( ref mut unwind) = * unwind {
729
+ Some ( unwind)
730
+ } else {
731
+ None
732
+ }
751
733
}
752
- _ => None
753
734
}
754
735
}
755
736
}
@@ -783,6 +764,18 @@ pub enum StatementKind<'tcx> {
783
764
cleanup : Option < Block >
784
765
} ,
785
766
767
+ /// Block ends with a call of a converging function
768
+ Call {
769
+ /// The function that’s being called
770
+ func : Operand < ' tcx > ,
771
+ /// Arguments the function is called with
772
+ args : Vec < Operand < ' tcx > > ,
773
+ /// Destination for the return value.
774
+ destination : Lvalue < ' tcx > ,
775
+ /// Cleanups to be done if the call unwinds.
776
+ cleanup : Option < Block >
777
+ } ,
778
+
786
779
/// No-op. Useful for deleting instructions without affecting statement indices.
787
780
Nop ,
788
781
}
@@ -820,6 +813,17 @@ impl<'tcx> Debug for Statement<'tcx> {
820
813
821
814
write ! ( fmt, ")" )
822
815
} ,
816
+ Call { ref func, ref args, ref destination, .. } => {
817
+ write ! ( fmt, "{:?} = " , destination) ?;
818
+ write ! ( fmt, "{:?}(" , func) ?;
819
+ for ( index, arg) in args. iter ( ) . enumerate ( ) {
820
+ if index > 0 {
821
+ write ! ( fmt, ", " ) ?;
822
+ }
823
+ write ! ( fmt, "{:?}" , arg) ?;
824
+ }
825
+ write ! ( fmt, ")" )
826
+ } ,
823
827
Nop => write ! ( fmt, "nop" ) ,
824
828
}
825
829
}
@@ -1459,6 +1463,16 @@ impl<'tcx> TypeFoldable<'tcx> for Statement<'tcx> {
1459
1463
cleanup : cleanup
1460
1464
}
1461
1465
} ,
1466
+ Call { ref func, ref args, ref destination, cleanup } => {
1467
+ let dest = destination. fold_with ( folder) ;
1468
+
1469
+ Call {
1470
+ func : func. fold_with ( folder) ,
1471
+ args : args. fold_with ( folder) ,
1472
+ destination : dest,
1473
+ cleanup : cleanup
1474
+ }
1475
+ } ,
1462
1476
Nop => Nop ,
1463
1477
} ;
1464
1478
Statement {
@@ -1488,6 +1502,10 @@ impl<'tcx> TypeFoldable<'tcx> for Statement<'tcx> {
1488
1502
false
1489
1503
}
1490
1504
} ,
1505
+ Call { ref func, ref args, ref destination, .. } => {
1506
+ destination. visit_with ( visitor) || func. visit_with ( visitor) ||
1507
+ args. visit_with ( visitor)
1508
+ } ,
1491
1509
Nop => false ,
1492
1510
}
1493
1511
}
@@ -1516,18 +1534,6 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
1516
1534
target : target,
1517
1535
unwind : unwind
1518
1536
} ,
1519
- Call { ref func, ref args, ref destination, cleanup } => {
1520
- let dest = destination. as_ref ( ) . map ( |& ( ref loc, dest) | {
1521
- ( loc. fold_with ( folder) , dest)
1522
- } ) ;
1523
-
1524
- Call {
1525
- func : func. fold_with ( folder) ,
1526
- args : args. fold_with ( folder) ,
1527
- destination : dest,
1528
- cleanup : cleanup
1529
- }
1530
- } ,
1531
1537
Resume => Resume ,
1532
1538
Return => Return ,
1533
1539
Unreachable => Unreachable ,
@@ -1547,12 +1553,6 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
1547
1553
Drop { ref location, ..} => location. visit_with ( visitor) ,
1548
1554
DropAndReplace { ref location, ref value, ..} =>
1549
1555
location. visit_with ( visitor) || value. visit_with ( visitor) ,
1550
- Call { ref func, ref args, ref destination, .. } => {
1551
- let dest = if let Some ( ( ref loc, _) ) = * destination {
1552
- loc. visit_with ( visitor)
1553
- } else { false } ;
1554
- dest || func. visit_with ( visitor) || args. visit_with ( visitor)
1555
- } ,
1556
1556
Goto { .. } |
1557
1557
Resume |
1558
1558
Return |
0 commit comments