mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-04 22:17:38 +00:00
Revert "Reduce the number of drop-flag assignments in unwind paths"
This reverts commit 54aa418a60
.
This commit is contained in:
parent
336d812761
commit
7cde4ab0d0
@ -362,7 +362,6 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
fn gather_terminator(&mut self, term: &Terminator<'tcx>) {
|
fn gather_terminator(&mut self, term: &Terminator<'tcx>) {
|
||||||
match term.kind {
|
match term.kind {
|
||||||
TerminatorKind::Goto { target: _ }
|
TerminatorKind::Goto { target: _ }
|
||||||
| TerminatorKind::Return
|
|
||||||
| TerminatorKind::Resume
|
| TerminatorKind::Resume
|
||||||
| TerminatorKind::Abort
|
| TerminatorKind::Abort
|
||||||
| TerminatorKind::GeneratorDrop
|
| TerminatorKind::GeneratorDrop
|
||||||
@ -370,6 +369,10 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
| TerminatorKind::FalseUnwind { .. }
|
| TerminatorKind::FalseUnwind { .. }
|
||||||
| TerminatorKind::Unreachable => {}
|
| TerminatorKind::Unreachable => {}
|
||||||
|
|
||||||
|
TerminatorKind::Return => {
|
||||||
|
self.gather_move(Place::return_place());
|
||||||
|
}
|
||||||
|
|
||||||
TerminatorKind::Assert { ref cond, .. } => {
|
TerminatorKind::Assert { ref cond, .. } => {
|
||||||
self.gather_operand(cond);
|
self.gather_operand(cond);
|
||||||
}
|
}
|
||||||
|
@ -233,6 +233,8 @@ where
|
|||||||
.patch_terminator(bb, TerminatorKind::Goto { target: self.succ });
|
.patch_terminator(bb, TerminatorKind::Goto { target: self.succ });
|
||||||
}
|
}
|
||||||
DropStyle::Static => {
|
DropStyle::Static => {
|
||||||
|
let loc = self.terminator_loc(bb);
|
||||||
|
self.elaborator.clear_drop_flag(loc, self.path, DropFlagMode::Deep);
|
||||||
self.elaborator.patch().patch_terminator(
|
self.elaborator.patch().patch_terminator(
|
||||||
bb,
|
bb,
|
||||||
TerminatorKind::Drop {
|
TerminatorKind::Drop {
|
||||||
@ -243,7 +245,9 @@ where
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
DropStyle::Conditional => {
|
DropStyle::Conditional => {
|
||||||
let drop_bb = self.complete_drop(self.succ, self.unwind);
|
let unwind = self.unwind; // FIXME(#43234)
|
||||||
|
let succ = self.succ;
|
||||||
|
let drop_bb = self.complete_drop(Some(DropFlagMode::Deep), succ, unwind);
|
||||||
self.elaborator
|
self.elaborator
|
||||||
.patch()
|
.patch()
|
||||||
.patch_terminator(bb, TerminatorKind::Goto { target: drop_bb });
|
.patch_terminator(bb, TerminatorKind::Goto { target: drop_bb });
|
||||||
@ -315,7 +319,7 @@ where
|
|||||||
// our own drop flag.
|
// our own drop flag.
|
||||||
path: self.path,
|
path: self.path,
|
||||||
}
|
}
|
||||||
.complete_drop(succ, unwind)
|
.complete_drop(None, succ, unwind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +348,13 @@ where
|
|||||||
// Clear the "master" drop flag at the end. This is needed
|
// Clear the "master" drop flag at the end. This is needed
|
||||||
// because the "master" drop protects the ADT's discriminant,
|
// because the "master" drop protects the ADT's discriminant,
|
||||||
// which is invalidated after the ADT is dropped.
|
// which is invalidated after the ADT is dropped.
|
||||||
(self.drop_flag_reset_block(DropFlagMode::Shallow, self.succ, self.unwind), self.unwind)
|
let (succ, unwind) = (self.succ, self.unwind); // FIXME(#43234)
|
||||||
|
(
|
||||||
|
self.drop_flag_reset_block(DropFlagMode::Shallow, succ, unwind),
|
||||||
|
unwind.map(|unwind| {
|
||||||
|
self.drop_flag_reset_block(DropFlagMode::Shallow, unwind, Unwind::InCleanup)
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a full drop ladder, consisting of 2 connected half-drop-ladders
|
/// Creates a full drop ladder, consisting of 2 connected half-drop-ladders
|
||||||
@ -878,7 +888,11 @@ where
|
|||||||
self.open_drop_for_adt(def, substs)
|
self.open_drop_for_adt(def, substs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind),
|
ty::Dynamic(..) => {
|
||||||
|
let unwind = self.unwind; // FIXME(#43234)
|
||||||
|
let succ = self.succ;
|
||||||
|
self.complete_drop(Some(DropFlagMode::Deep), succ, unwind)
|
||||||
|
}
|
||||||
ty::Array(ety, size) => {
|
ty::Array(ety, size) => {
|
||||||
let size = size.try_eval_usize(self.tcx(), self.elaborator.param_env());
|
let size = size.try_eval_usize(self.tcx(), self.elaborator.param_env());
|
||||||
self.open_drop_for_array(ety, size)
|
self.open_drop_for_array(ety, size)
|
||||||
@ -889,10 +903,20 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
|
fn complete_drop(
|
||||||
debug!("complete_drop(succ={:?}, unwind={:?})", succ, unwind);
|
&mut self,
|
||||||
|
drop_mode: Option<DropFlagMode>,
|
||||||
|
succ: BasicBlock,
|
||||||
|
unwind: Unwind,
|
||||||
|
) -> BasicBlock {
|
||||||
|
debug!("complete_drop({:?},{:?})", self, drop_mode);
|
||||||
|
|
||||||
let drop_block = self.drop_block(succ, unwind);
|
let drop_block = self.drop_block(succ, unwind);
|
||||||
|
let drop_block = if let Some(mode) = drop_mode {
|
||||||
|
self.drop_flag_reset_block(mode, drop_block, unwind)
|
||||||
|
} else {
|
||||||
|
drop_block
|
||||||
|
};
|
||||||
|
|
||||||
self.drop_flag_test_block(drop_block, succ, unwind)
|
self.drop_flag_test_block(drop_block, succ, unwind)
|
||||||
}
|
}
|
||||||
@ -907,11 +931,6 @@ where
|
|||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
debug!("drop_flag_reset_block({:?},{:?})", self, mode);
|
debug!("drop_flag_reset_block({:?},{:?})", self, mode);
|
||||||
|
|
||||||
if unwind.is_cleanup() {
|
|
||||||
// The drop flag isn't read again on the unwind path, so don't
|
|
||||||
// bother setting it.
|
|
||||||
return succ;
|
|
||||||
}
|
|
||||||
let block = self.new_block(unwind, TerminatorKind::Goto { target: succ });
|
let block = self.new_block(unwind, TerminatorKind::Goto { target: succ });
|
||||||
let block_start = Location { block, statement_index: 0 };
|
let block_start = Location { block, statement_index: 0 };
|
||||||
self.elaborator.clear_drop_flag(block_start, self.path, mode);
|
self.elaborator.clear_drop_flag(block_start, self.path, mode);
|
||||||
@ -1028,6 +1047,11 @@ where
|
|||||||
self.elaborator.patch().new_temp(ty, self.source_info.span)
|
self.elaborator.patch().new_temp(ty, self.source_info.span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn terminator_loc(&mut self, bb: BasicBlock) -> Location {
|
||||||
|
let body = self.elaborator.body();
|
||||||
|
self.elaborator.patch().terminator_loc(body, bb)
|
||||||
|
}
|
||||||
|
|
||||||
fn constant_usize(&self, val: u16) -> Operand<'tcx> {
|
fn constant_usize(&self, val: u16) -> Operand<'tcx> {
|
||||||
Operand::Constant(box Constant {
|
Operand::Constant(box Constant {
|
||||||
span: self.source_info.span,
|
span: self.source_info.span,
|
||||||
|
Loading…
Reference in New Issue
Block a user