1
Fork 0

Mark early otherwise optimization unsound

This commit is contained in:
Santiago Pastorino 2021-03-18 17:35:46 -03:00
parent 1705a7d64b
commit 778e1978d5
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
3 changed files with 7 additions and 2 deletions

View file

@ -26,6 +26,11 @@ pub struct EarlyOtherwiseBranch;
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// FIXME(#78496)
if !tcx.sess.opts.debugging_opts.unsound_mir_opts {
return;
}
if tcx.sess.mir_opt_level() < 3 { if tcx.sess.mir_opt_level() < 3 {
return; return;
} }

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=4 // compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts
// EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<u32>, y: Option<u32>) -> u32 { fn opt1(x: Option<u32>, y: Option<u32>) -> u32 {
match (x, y) { match (x, y) {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=4 // compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts
// EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 { fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 {