Move save_work_product_index call out of cg_llvm
This commit is contained in:
parent
46f2f023b0
commit
69f45cd965
3 changed files with 18 additions and 16 deletions
|
@ -23,8 +23,9 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig};
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::ModuleCodegen;
|
use rustc_codegen_ssa::ModuleCodegen;
|
||||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
||||||
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{ErrorReported, FatalError, Handler};
|
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::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_serialize::json;
|
use rustc_serialize::json;
|
||||||
|
@ -274,8 +275,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||||
&self,
|
&self,
|
||||||
ongoing_codegen: Box<dyn Any>,
|
ongoing_codegen: Box<dyn Any>,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
dep_graph: &DepGraph,
|
) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||||
) -> Result<Box<dyn Any>, ErrorReported> {
|
|
||||||
let (codegen_results, work_products) = ongoing_codegen
|
let (codegen_results, work_products) = ongoing_codegen
|
||||||
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
|
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
|
||||||
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
|
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
|
||||||
|
@ -284,13 +284,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||||
rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
|
rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.time("serialize_work_products", move || {
|
Ok((Box::new(codegen_results), work_products))
|
||||||
rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
|
|
||||||
});
|
|
||||||
|
|
||||||
sess.compile_status()?;
|
|
||||||
|
|
||||||
Ok(Box::new(codegen_results))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link(
|
fn link(
|
||||||
|
|
|
@ -3,8 +3,9 @@ use super::CodegenObject;
|
||||||
use crate::ModuleCodegen;
|
use crate::ModuleCodegen;
|
||||||
|
|
||||||
use rustc_ast::expand::allocator::AllocatorKind;
|
use rustc_ast::expand::allocator::AllocatorKind;
|
||||||
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::ErrorReported;
|
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::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||||
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
|
@ -80,8 +81,7 @@ pub trait CodegenBackend {
|
||||||
&self,
|
&self,
|
||||||
ongoing_codegen: Box<dyn Any>,
|
ongoing_codegen: Box<dyn Any>,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
dep_graph: &DepGraph,
|
) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>;
|
||||||
) -> Result<Box<dyn Any>, ErrorReported>;
|
|
||||||
|
|
||||||
/// This is called on the returned `Box<dyn Any>` from `join_codegen`
|
/// This is called on the returned `Box<dyn Any>` from `join_codegen`
|
||||||
///
|
///
|
||||||
|
|
|
@ -356,10 +356,18 @@ pub struct Linker {
|
||||||
|
|
||||||
impl Linker {
|
impl Linker {
|
||||||
pub fn link(self) -> Result<()> {
|
pub fn link(self) -> Result<()> {
|
||||||
let codegen_results =
|
let (codegen_results, work_products) =
|
||||||
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess, &self.dep_graph)?;
|
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?;
|
||||||
let prof = self.sess.prof.clone();
|
|
||||||
|
self.sess.compile_status()?;
|
||||||
|
|
||||||
|
let sess = &self.sess;
|
||||||
let dep_graph = self.dep_graph;
|
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));
|
prof.generic_activity("drop_dep_graph").run(move || drop(dep_graph));
|
||||||
|
|
||||||
if !self
|
if !self
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue