Skip to content

Commit 5e08e7f

Browse files
authored
Unrolled build for #147092
Rollup merge of #147092 - cjgillot:late-validate-mir, r=compiler-errors Do not compute optimized MIR if code does not type-check. Since #128612, we compute optimized MIR when `-Zvalidate-mir` is present. This is done as part of required analyses, even if type-checking fails. This causes ICEs, as most of the mir-opt pipeline expects well-formed code. Fixes #129095 Fixes #134174 Fixes #134654 Fixes #135570 Fixes #136381 Fixes #137468 Fixes #144491 Fixes #147011 This does not fix issue #137190, as it ICEs without `-Zvalidate-mir`. r? ``@compiler-errors``
2 parents 772f380 + 7a7cb05 commit 5e08e7f

File tree

8 files changed

+14
-116
lines changed

8 files changed

+14
-116
lines changed

compiler/rustc_interface/src/passes.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,18 +1122,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11221122

11231123
sess.time("layout_testing", || layout_test::test_layout(tcx));
11241124
sess.time("abi_testing", || abi_test::test_abi(tcx));
1125-
1126-
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
1127-
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
1128-
// in MIR optimizations that may only be reachable through codegen, or other codepaths
1129-
// that requires the optimized/ctfe MIR, coroutine bodies, or evaluating consts.
1130-
if tcx.sess.opts.unstable_opts.validate_mir {
1131-
sess.time("ensuring_final_MIR_is_computable", || {
1132-
tcx.par_hir_body_owners(|def_id| {
1133-
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
1134-
});
1135-
});
1136-
}
11371125
}
11381126

11391127
/// Runs the type-checking, region checking and other miscellaneous analysis
@@ -1199,6 +1187,20 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
11991187
// we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
12001188
let _ = tcx.all_diagnostic_items(());
12011189
});
1190+
1191+
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
1192+
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
1193+
// in MIR optimizations that may only be reachable through codegen, or other codepaths
1194+
// that requires the optimized/ctfe MIR, coroutine bodies, or evaluating consts.
1195+
// Nevertheless, wait after type checking is finished, as optimizing code that does not
1196+
// type-check is very prone to ICEs.
1197+
if tcx.sess.opts.unstable_opts.validate_mir {
1198+
sess.time("ensuring_final_MIR_is_computable", || {
1199+
tcx.par_hir_body_owners(|def_id| {
1200+
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
1201+
});
1202+
});
1203+
}
12021204
}
12031205

12041206
/// Runs the codegen backend, after which the AST and analysis can

tests/crashes/129095.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/crashes/134174.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/crashes/134654.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/crashes/135570.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/crashes/136381.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/crashes/137190-1.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/crashes/137468.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)