]> git.lizzy.rs Git - rust.git/commitdiff
add a -Z flag to guarantee that MIR is generated for all functions
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 7 Dec 2016 12:22:21 +0000 (13:22 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 7 Dec 2016 12:22:21 +0000 (13:22 +0100)
src/librustc/session/config.rs
src/librustc_metadata/encoder.rs

index 47f0de3ce5770c3e46ddcbb061ae05c0e66bc8cb..17b572e7f9e432270e0046903927bcc48fcce3b2 100644 (file)
@@ -928,6 +928,8 @@ fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bo
           "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 {
index 01cb0f823e8efae6455f31a11bec20f9e2234661..d9bcdb36026e5a34c3b2c02f2eb66794db8c9917 100644 (file)
@@ -577,7 +577,8 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'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 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
                 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