Skip to content

Commit 69f45cd

Browse files
committed
Move save_work_product_index call out of cg_llvm
1 parent 46f2f02 commit 69f45cd

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig};
2323
use rustc_codegen_ssa::traits::*;
2424
use rustc_codegen_ssa::ModuleCodegen;
2525
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
26+
use rustc_data_structures::fx::FxHashMap;
2627
use rustc_errors::{ErrorReported, FatalError, Handler};
27-
use rustc_middle::dep_graph::{DepGraph, WorkProduct};
28+
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2829
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
2930
use rustc_middle::ty::{self, TyCtxt};
3031
use rustc_serialize::json;
@@ -274,8 +275,7 @@ impl CodegenBackend for LlvmCodegenBackend {
274275
&self,
275276
ongoing_codegen: Box<dyn Any>,
276277
sess: &Session,
277-
dep_graph: &DepGraph,
278-
) -> Result<Box<dyn Any>, ErrorReported> {
278+
) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
279279
let (codegen_results, work_products) = ongoing_codegen
280280
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
281281
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
@@ -284,13 +284,7 @@ impl CodegenBackend for LlvmCodegenBackend {
284284
rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
285285
}
286286

287-
sess.time("serialize_work_products", move || {
288-
rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
289-
});
290-
291-
sess.compile_status()?;
292-
293-
Ok(Box::new(codegen_results))
287+
Ok((Box::new(codegen_results), work_products))
294288
}
295289

296290
fn link(

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use super::CodegenObject;
33
use crate::ModuleCodegen;
44

55
use rustc_ast::expand::allocator::AllocatorKind;
6+
use rustc_data_structures::fx::FxHashMap;
67
use rustc_errors::ErrorReported;
7-
use rustc_middle::dep_graph::DepGraph;
8+
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
89
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
910
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
1011
use rustc_middle::ty::query::Providers;
@@ -80,8 +81,7 @@ pub trait CodegenBackend {
8081
&self,
8182
ongoing_codegen: Box<dyn Any>,
8283
sess: &Session,
83-
dep_graph: &DepGraph,
84-
) -> Result<Box<dyn Any>, ErrorReported>;
84+
) -> Result<(Box<dyn Any>, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>;
8585

8686
/// This is called on the returned `Box<dyn Any>` from `join_codegen`
8787
///

compiler/rustc_interface/src/queries.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,18 @@ pub struct Linker {
356356

357357
impl Linker {
358358
pub fn link(self) -> Result<()> {
359-
let codegen_results =
360-
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess, &self.dep_graph)?;
361-
let prof = self.sess.prof.clone();
359+
let (codegen_results, work_products) =
360+
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?;
361+
362+
self.sess.compile_status()?;
363+
364+
let sess = &self.sess;
362365
let dep_graph = self.dep_graph;
366+
sess.time("serialize_work_products", || {
367+
rustc_incremental::save_work_product_index(&sess, &dep_graph, work_products)
368+
});
369+
370+
let prof = self.sess.prof.clone();
363371
prof.generic_activity("drop_dep_graph").run(move || drop(dep_graph));
364372

365373
if !self

0 commit comments

Comments
 (0)