Skip to content

Commit

Permalink
add a -Z flag to guarantee that MIR is generated for all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 7, 2016
1 parent 02ea82d commit 87a9ae2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -928,6 +928,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"print some statistics about AST and HIR"),
mir_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about MIR"),
always_encode_mir: bool = (false, parse_bool, [TRACKED],
"encode MIR of all functions into the crate metadata"),
}

pub fn default_lib_output() -> CrateType {
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_metadata/encoder.rs
Expand Up @@ -577,7 +577,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let types = generics.parent_types as usize + generics.types.len();
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
let is_const_fn = sig.constness == hir::Constness::Const;
(is_const_fn, needs_inline || is_const_fn)
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
(is_const_fn, needs_inline || is_const_fn || always_encode_mir)
} else {
(false, false)
};
Expand Down Expand Up @@ -842,7 +843,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
hir::ItemFn(_, _, constness, _, ref generics, _) => {
let tps_len = generics.ty_params.len();
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
if needs_inline || constness == hir::Constness::Const {
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
if needs_inline || constness == hir::Constness::Const || always_encode_mir {
self.encode_mir(def_id)
} else {
None
Expand Down

0 comments on commit 87a9ae2

Please sign in to comment.