summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_mir_transform/src/abort_unwinding_calls.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_mir_transform/src/abort_unwinding_calls.rs')
-rw-r--r--compiler/rustc_mir_transform/src/abort_unwinding_calls.rs32
1 files changed, 5 insertions, 27 deletions
diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs
index 9b4b72070..5aed89139 100644
--- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs
+++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs
@@ -34,11 +34,6 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
return;
}
- // This pass only runs on functions which themselves cannot unwind,
- // forcibly changing the body of the function to structurally provide
- // this guarantee by aborting on an unwind. If this function can unwind,
- // then there's nothing to do because it already should work correctly.
- //
// Here we test for this function itself whether its ABI allows
// unwinding or not.
let body_ty = tcx.type_of(def_id).skip_binder();
@@ -74,7 +69,7 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
};
layout::fn_can_unwind(tcx, fn_def_id, sig.abi())
}
- TerminatorKind::Drop { .. } | TerminatorKind::DropAndReplace { .. } => {
+ TerminatorKind::Drop { .. } => {
tcx.sess.opts.unstable_opts.panic_in_drop == PanicStrategy::Unwind
&& layout::fn_can_unwind(tcx, None, Abi::Rust)
}
@@ -107,31 +102,14 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
}
}
- // For call instructions which need to be terminated, we insert a
- // singular basic block which simply terminates, and then configure the
- // `cleanup` attribute for all calls we found to this basic block we
- // insert which means that any unwinding that happens in the functions
- // will force an abort of the process.
- if !calls_to_terminate.is_empty() {
- let bb = BasicBlockData {
- statements: Vec::new(),
- is_cleanup: true,
- terminator: Some(Terminator {
- source_info: SourceInfo::outermost(body.span),
- kind: TerminatorKind::Abort,
- }),
- };
- let abort_bb = body.basic_blocks_mut().push(bb);
-
- for bb in calls_to_terminate {
- let cleanup = body.basic_blocks_mut()[bb].terminator_mut().unwind_mut().unwrap();
- *cleanup = Some(abort_bb);
- }
+ for id in calls_to_terminate {
+ let cleanup = body.basic_blocks_mut()[id].terminator_mut().unwind_mut().unwrap();
+ *cleanup = UnwindAction::Terminate;
}
for id in cleanups_to_remove {
let cleanup = body.basic_blocks_mut()[id].terminator_mut().unwind_mut().unwrap();
- *cleanup = None;
+ *cleanup = UnwindAction::Unreachable;
}
// We may have invalidated some `cleanup` blocks so clean those up now.