]> git.lizzy.rs Git - rust.git/commitdiff
Move save_work_product_index call out of cg_llvm
authorbjorn3 <bjorn3@users.noreply.github.com>
Sat, 10 Oct 2020 13:14:58 +0000 (15:14 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Sat, 10 Oct 2020 13:14:58 +0000 (15:14 +0200)
compiler/rustc_codegen_llvm/src/lib.rs
compiler/rustc_codegen_ssa/src/traits/backend.rs
compiler/rustc_interface/src/queries.rs

index e15248d8432850014869560276c911444addbccb..b3328deebe8bf2f432a53e20ad44d109c1dd7a88 100644 (file)
@@ -23,8 +23,9 @@
 use rustc_codegen_ssa::traits::*;
 use rustc_codegen_ssa::ModuleCodegen;
 use rustc_codegen_ssa::{CodegenResults, CompiledModule};
+use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::{ErrorReported, FatalError, Handler};
-use rustc_middle::dep_graph::{DepGraph, WorkProduct};
+use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
 use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
 use rustc_middle::ty::{self, TyCtxt};
 use rustc_serialize::json;
@@ -274,8 +275,7 @@ fn join_codegen(
         &self,
         ongoing_codegen: Box<dyn Any>,
         sess: &Session,
-        dep_graph: &DepGraph,
-    ) -> Result<Box<dyn Any>, ErrorReported> {
+    ) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
         let (codegen_results, work_products) = ongoing_codegen
             .downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
             .expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
@@ -284,13 +284,7 @@ fn join_codegen(
             rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
         }
 
-        sess.time("serialize_work_products", move || {
-            rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
-        });
-
-        sess.compile_status()?;
-
-        Ok(Box::new(codegen_results))
+        Ok((Box::new(codegen_results), work_products))
     }
 
     fn link(
index 48c07b0089420559557219d5928054035bad3b4c..4a88f747a17ffa71e51b36a9669e479b3b655322 100644 (file)
@@ -3,8 +3,9 @@
 use crate::ModuleCodegen;
 
 use rustc_ast::expand::allocator::AllocatorKind;
+use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::ErrorReported;
-use rustc_middle::dep_graph::DepGraph;
+use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
 use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
 use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
 use rustc_middle::ty::query::Providers;
@@ -80,8 +81,7 @@ fn join_codegen(
         &self,
         ongoing_codegen: Box<dyn Any>,
         sess: &Session,
-        dep_graph: &DepGraph,
-    ) -> Result<Box<dyn Any>, ErrorReported>;
+    ) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>;
 
     /// This is called on the returned `Box<dyn Any>` from `join_codegen`
     ///
index 8b82217a91ac6e0357b852a97d78b63686334063..b7e4c097c900d09ff1ec5d615ae7c745fde57a0a 100644 (file)
@@ -356,10 +356,18 @@ pub struct Linker {
 
 impl Linker {
     pub fn link(self) -> Result<()> {
-        let codegen_results =
-            self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess, &self.dep_graph)?;
-        let prof = self.sess.prof.clone();
+        let (codegen_results, work_products) =
+            self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?;
+
+        self.sess.compile_status()?;
+
+        let sess = &self.sess;
         let dep_graph = self.dep_graph;
+        sess.time("serialize_work_products", || {
+            rustc_incremental::save_work_product_index(&sess, &dep_graph, work_products)
+        });
+
+        let prof = self.sess.prof.clone();
         prof.generic_activity("drop_dep_graph").run(move || drop(dep_graph));
 
         if !self