Rollup merge of #83277 - spastorino:early_otherwise-opt-unsound, r=oli-obk

Mark early otherwise optimization unsound

r? `@oli-obk`
cc `@tmiasko`

Related to #78496 and #82905

Should I also bump this one to level 3 or 4 or given that is unsound it doesn't matter?.
Probably need to adjust some tests.
This commit is contained in:
Dylan DPC 2021-03-19 23:01:40 +01:00 committed by GitHub
commit 90e52a1ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,11 @@ pub struct EarlyOtherwiseBranch;
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
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 {
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
fn opt1(x: Option<u32>, y: Option<u32>) -> u32 {
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
fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 {