Skip to content

Commit 87a9ae2

Browse files
committed
add a -Z flag to guarantee that MIR is generated for all functions
1 parent 02ea82d commit 87a9ae2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
928928
"print some statistics about AST and HIR"),
929929
mir_stats: bool = (false, parse_bool, [UNTRACKED],
930930
"print some statistics about MIR"),
931+
always_encode_mir: bool = (false, parse_bool, [TRACKED],
932+
"encode MIR of all functions into the crate metadata"),
931933
}
932934

933935
pub fn default_lib_output() -> CrateType {

src/librustc_metadata/encoder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
577577
let types = generics.parent_types as usize + generics.types.len();
578578
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
579579
let is_const_fn = sig.constness == hir::Constness::Const;
580-
(is_const_fn, needs_inline || is_const_fn)
580+
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
581+
(is_const_fn, needs_inline || is_const_fn || always_encode_mir)
581582
} else {
582583
(false, false)
583584
};
@@ -842,7 +843,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
842843
hir::ItemFn(_, _, constness, _, ref generics, _) => {
843844
let tps_len = generics.ty_params.len();
844845
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
845-
if needs_inline || constness == hir::Constness::Const {
846+
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
847+
if needs_inline || constness == hir::Constness::Const || always_encode_mir {
846848
self.encode_mir(def_id)
847849
} else {
848850
None

0 commit comments

Comments
 (0)