Skip to content

Commit 1e07c19

Browse files
Make validate_mir pull optimized/ctfe MIR for all bodies
1 parent a604303 commit 1e07c19

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

compiler/rustc_interface/src/passes.rs

+13
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,19 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
818818
});
819819
sess.time("layout_testing", || layout_test::test_layout(tcx));
820820
sess.time("abi_testing", || abi_test::test_abi(tcx));
821+
822+
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
823+
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
824+
// in MIR optimizations that may only be reachable through codegen, or other codepaths
825+
// that requires the optimized/ctfe MIR, such as polymorphization, coroutine bodies,
826+
// or evaluating consts.
827+
if tcx.sess.opts.unstable_opts.validate_mir {
828+
sess.time("ensuring_final_MIR_is_computable", || {
829+
tcx.hir().par_body_owners(|def_id| {
830+
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
831+
});
832+
});
833+
}
821834
}
822835

823836
/// Runs the type-checking, region checking and other miscellaneous analysis

tests/crashes/121127.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ known-bug: #121127
2-
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -C debuginfo=2
2+
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes -C debuginfo=2
33
// Note that as of PR#123949 this only crashes with debuginfo enabled
44

55
#![feature(specialization)]

tests/crashes/122909.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
1+
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
22
//@ known-bug: #122909
33

44

tests/crashes/126896.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ known-bug: rust-lang/rust#126896
2-
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
2+
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
33

44
#![feature(type_alias_impl_trait)]
55
type Two<'a, 'b> = impl std::fmt::Debug;

0 commit comments

Comments
 (0)