cache the terminate block with the last reason that we saw
This commit is contained in:
parent
ddea3f981e
commit
114fde6ac7
3 changed files with 16 additions and 21 deletions
|
@ -1581,8 +1581,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
|
||||
fn terminate_block(&mut self, reason: UnwindTerminateReason) -> Bx::BasicBlock {
|
||||
if let Some(bb) = self.terminate_in_cleanup_block && reason == UnwindTerminateReason::InCleanup {
|
||||
return bb;
|
||||
if let Some((cached_bb, cached_reason)) = self.terminate_block && reason == cached_reason {
|
||||
return cached_bb;
|
||||
}
|
||||
|
||||
let funclet;
|
||||
|
@ -1653,9 +1653,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
|
||||
bx.unreachable();
|
||||
|
||||
if reason == UnwindTerminateReason::InCleanup {
|
||||
self.terminate_in_cleanup_block = Some(llbb);
|
||||
}
|
||||
self.terminate_block = Some((llbb, reason));
|
||||
llbb
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use rustc_index::IndexVec;
|
|||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::mir::traversal;
|
||||
use rustc_middle::mir::UnwindTerminateReason;
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
||||
use rustc_target::abi::call::{FnAbi, PassMode};
|
||||
|
@ -83,8 +84,8 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
|||
/// Cached unreachable block
|
||||
unreachable_block: Option<Bx::BasicBlock>,
|
||||
|
||||
/// Cached terminate upon unwinding (reason: InCleanup) block
|
||||
terminate_in_cleanup_block: Option<Bx::BasicBlock>,
|
||||
/// Cached terminate upon unwinding block and its reason
|
||||
terminate_block: Option<(Bx::BasicBlock, UnwindTerminateReason)>,
|
||||
|
||||
/// The location where each MIR arg/var/tmp/ret is stored. This is
|
||||
/// usually an `PlaceRef` representing an alloca, but not always:
|
||||
|
@ -199,7 +200,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
personality_slot: None,
|
||||
cached_llbbs,
|
||||
unreachable_block: None,
|
||||
terminate_in_cleanup_block: None,
|
||||
terminate_block: None,
|
||||
cleanup_kinds,
|
||||
landing_pads: IndexVec::from_elem(None, &mir.basic_blocks),
|
||||
funclets: IndexVec::from_fn_n(|_| None, mir.basic_blocks.len()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue