Skip to content

Commit

Permalink
UnwindTerminate now have reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Aug 26, 2023
1 parent d644183 commit 2f2962e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/monomorphize_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
let source = self.body.source_info(location).span;

let tcx = self.tcx;
let push_mono_lang_item = |this: &mut Self, lang_item: LangItem| {
let instance = Instance::mono(tcx, tcx.require_lang_item(lang_item, Some(source)));
this.output.push(create_fn_mono_item(tcx, instance, source));
};

match terminator.kind {
mir::TerminatorKind::Call { ref func, .. } => {
let callee_ty = func.ty(self.body, tcx);
Expand Down Expand Up @@ -658,15 +663,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck,
_ => LangItem::Panic,
};
let instance = Instance::mono(tcx, tcx.require_lang_item(lang_item, Some(source)));
self.output.push(create_fn_mono_item(tcx, instance, source));
push_mono_lang_item(self, lang_item);
}
mir::TerminatorKind::UnwindTerminate => {
let instance = Instance::mono(
tcx,
tcx.require_lang_item(LangItem::PanicCannotUnwind, Some(source)),
);
self.output.push(create_fn_mono_item(tcx, instance, source));
mir::TerminatorKind::UnwindTerminate(reason) => {
push_mono_lang_item(self, reason.lang_item());
}
mir::TerminatorKind::Goto { .. }
| mir::TerminatorKind::SwitchInt { .. }
Expand All @@ -679,6 +679,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
| mir::TerminatorKind::FalseUnwind { .. } => bug!(),
}

if let Some(mir::UnwindAction::Terminate(reason)) = terminator.unwind() {
push_mono_lang_item(self, reason.lang_item());
}

self.super_terminator(terminator, location);
}

Expand Down
2 changes: 1 addition & 1 deletion src/preempt_count/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<'mir, 'tcx, 'cx> MirNeighborVisitor<'mir, 'tcx, 'cx> {
}
}
mir::TerminatorKind::Assert { .. }
| mir::TerminatorKind::UnwindTerminate
| mir::TerminatorKind::UnwindTerminate { .. }
| mir::TerminatorKind::Goto { .. }
| mir::TerminatorKind::SwitchInt { .. }
| mir::TerminatorKind::UnwindResume
Expand Down

0 comments on commit 2f2962e

Please sign in to comment.