add some comments explaining why MIR opts are marked as unsound

This commit is contained in:
Ralf Jung 2023-10-10 11:17:27 +02:00
parent 2de454637f
commit d805b265db
3 changed files with 5 additions and 1 deletions

View File

@ -95,6 +95,7 @@ pub struct EarlyOtherwiseBranch;
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
// unsound: https://github.com/rust-lang/rust/issues/95162
sess.mir_opt_level() >= 3 && sess.opts.unstable_opts.unsound_mir_opts sess.mir_opt_level() >= 3 && sess.opts.unstable_opts.unsound_mir_opts
} }

View File

@ -30,6 +30,9 @@ pub struct EnumSizeOpt {
impl<'tcx> MirPass<'tcx> for EnumSizeOpt { impl<'tcx> MirPass<'tcx> for EnumSizeOpt {
fn is_enabled(&self, sess: &Session) -> bool { fn is_enabled(&self, sess: &Session) -> bool {
// There are some differences in behavior on wasm and ARM that are not properly
// understood, so we conservatively treat this optimization as unsound:
// https://github.com/rust-lang/rust/pull/85158#issuecomment-1101836457
sess.opts.unstable_opts.unsound_mir_opts || sess.mir_opt_level() >= 3 sess.opts.unstable_opts.unsound_mir_opts || sess.mir_opt_level() >= 3
} }
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

View File

@ -34,7 +34,7 @@ pub struct RenameReturnPlace;
impl<'tcx> MirPass<'tcx> for RenameReturnPlace { impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
// #111005 // unsound: #111005
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
} }