add a -Z flag to guarantee that MIR is generated for all functions

This commit is contained in:
Oliver Schneider 2016-12-07 13:22:21 +01:00
parent 02ea82ddb8
commit 87a9ae224d
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46
2 changed files with 6 additions and 2 deletions

View File

@ -928,6 +928,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"print some statistics about AST and HIR"), "print some statistics about AST and HIR"),
mir_stats: bool = (false, parse_bool, [UNTRACKED], mir_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about MIR"), "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 { pub fn default_lib_output() -> CrateType {

View File

@ -577,7 +577,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let types = generics.parent_types as usize + generics.types.len(); let types = generics.parent_types as usize + generics.types.len();
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs); let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
let is_const_fn = sig.constness == hir::Constness::Const; 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 { } else {
(false, false) (false, false)
}; };
@ -842,7 +843,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
hir::ItemFn(_, _, constness, _, ref generics, _) => { hir::ItemFn(_, _, constness, _, ref generics, _) => {
let tps_len = generics.ty_params.len(); let tps_len = generics.ty_params.len();
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs); 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) self.encode_mir(def_id)
} else { } else {
None None