@@ -57,10 +57,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
57
57
kind : TerminatorKind :: Call { target : Some ( ref mut destination) , unwind, .. } ,
58
58
source_info,
59
59
} ) if pred_count[ * destination] > 1
60
- && ( matches ! (
61
- unwind,
62
- UnwindAction :: Cleanup ( _) | UnwindAction :: Terminate ( _)
63
- ) || self == & AllCallEdges ) =>
60
+ && ( generates_invoke ( unwind) || self == & AllCallEdges ) =>
64
61
{
65
62
// It's a critical edge, break it
66
63
* destination = new_block ( source_info, block. is_cleanup , * destination) ;
@@ -81,9 +78,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
81
78
} ) ;
82
79
let has_labels =
83
80
operands. iter ( ) . any ( |op| matches ! ( op, InlineAsmOperand :: Label { .. } ) ) ;
84
- let invoke =
85
- matches ! ( unwind, UnwindAction :: Cleanup ( _) | UnwindAction :: Terminate ( _) ) ;
86
- if has_outputs && ( has_labels || invoke) {
81
+ if has_outputs && ( has_labels || generates_invoke ( unwind) ) {
87
82
for target in targets. iter_mut ( ) {
88
83
if pred_count[ * target] > 1 {
89
84
* target = new_block ( source_info, block. is_cleanup , * target) ;
@@ -104,3 +99,11 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
104
99
true
105
100
}
106
101
}
102
+
103
+ /// Returns true if this unwind action is code generated as an invoke as opposed to a call.
104
+ fn generates_invoke ( unwind : UnwindAction ) -> bool {
105
+ match unwind {
106
+ UnwindAction :: Continue | UnwindAction :: Unreachable => false ,
107
+ UnwindAction :: Cleanup ( _) | UnwindAction :: Terminate ( _) => true ,
108
+ }
109
+ }
0 commit comments