add a -Z flag to guarantee that MIR is generated for all functions
This commit is contained in:
parent
02ea82ddb8
commit
87a9ae224d
@ -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 {
|
||||
|
@ -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)
|
||||
};
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user