Skip to content

Commit de4980c

Browse files
authored
Rollup merge of #116595 - RalfJung:mir-enable-passes, r=oli-obk
-Zmir-enable-passes: document that this may enable unsound passes also add some comments explaining why MIR opts are marked as unsound
2 parents f4de82c + d805b26 commit de4980c

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

Diff for: compiler/rustc_mir_transform/src/early_otherwise_branch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub struct EarlyOtherwiseBranch;
9595

9696
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
9797
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
98+
// unsound: https://github.com/rust-lang/rust/issues/95162
9899
sess.mir_opt_level() >= 3 && sess.opts.unstable_opts.unsound_mir_opts
99100
}
100101

Diff for: compiler/rustc_mir_transform/src/large_enums.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct EnumSizeOpt {
3030

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

Diff for: compiler/rustc_mir_transform/src/nrvo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct RenameReturnPlace;
3434

3535
impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
3636
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
37-
// #111005
37+
// unsound: #111005
3838
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
3939
}
4040

Diff for: compiler/rustc_session/src/options.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1599,9 +1599,10 @@ options! {
15991599
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
16001600
(default: no)"),
16011601
mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED],
1602-
"use like `-Zmir-enable-passes=+DestinationPropagation,-InstSimplify`. Forces the specified passes to be \
1603-
enabled, overriding all other checks. Passes that are not specified are enabled or \
1604-
disabled by other flags as usual."),
1602+
"use like `-Zmir-enable-passes=+DestinationPropagation,-InstSimplify`. Forces the \
1603+
specified passes to be enabled, overriding all other checks. In particular, this will \
1604+
enable unsound (known-buggy and hence usually disabled) passes without further warning! \
1605+
Passes that are not specified are enabled or disabled by other flags as usual."),
16051606
mir_include_spans: bool = (false, parse_bool, [UNTRACKED],
16061607
"use line numbers relative to the function in mir pretty printing"),
16071608
mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],

0 commit comments

Comments
 (0)