@@ -57,10 +57,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
5757 kind : TerminatorKind :: Call { target : Some ( ref mut destination) , unwind, .. } ,
5858 source_info,
5959 } ) if pred_count[ * destination] > 1
60- && ( matches ! (
61- unwind,
62- UnwindAction :: Cleanup ( _) | UnwindAction :: Terminate ( _)
63- ) || self == & AllCallEdges ) =>
60+ && ( generates_invoke ( unwind) || self == & AllCallEdges ) =>
6461 {
6562 // It's a critical edge, break it
6663 * destination = new_block ( source_info, block. is_cleanup , * destination) ;
@@ -81,9 +78,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
8178 } ) ;
8279 let has_labels =
8380 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) ) {
8782 for target in targets. iter_mut ( ) {
8883 if pred_count[ * target] > 1 {
8984 * target = new_block ( source_info, block. is_cleanup , * target) ;
@@ -104,3 +99,11 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
10499 true
105100 }
106101}
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