Codegen const panic messages as function calls
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
This commit is contained in:
parent
0ad927c0c0
commit
00f4daa276
12 changed files with 255 additions and 63 deletions
|
@ -971,16 +971,17 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
mir::TerminatorKind::Assert { ref msg, .. } => {
|
||||
let lang_item = match &**msg {
|
||||
mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck,
|
||||
mir::AssertKind::MisalignedPointerDereference { .. } => {
|
||||
LangItem::PanicMisalignedPointerDereference
|
||||
}
|
||||
_ => LangItem::Panic,
|
||||
};
|
||||
push_mono_lang_item(self, lang_item);
|
||||
}
|
||||
mir::TerminatorKind::Assert { ref msg, .. } => match &**msg {
|
||||
mir::AssertKind::BoundsCheck { .. } => {
|
||||
push_mono_lang_item(self, LangItem::PanicBoundsCheck);
|
||||
}
|
||||
mir::AssertKind::MisalignedPointerDereference { .. } => {
|
||||
push_mono_lang_item(self, LangItem::PanicMisalignedPointerDereference);
|
||||
}
|
||||
_ => {
|
||||
push_mono_lang_item(self, msg.panic_function());
|
||||
}
|
||||
},
|
||||
mir::TerminatorKind::UnwindTerminate(reason) => {
|
||||
push_mono_lang_item(self, reason.lang_item());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue