Skip to content

Commit ed2f5ba

Browse files
committed
Reuse determine_cgu_reuse from cg_ssa in cg_clif
1 parent 5d85a24 commit ed2f5ba

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/driver/aot.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::thread::JoinHandle;
88

99
use cranelift_object::{ObjectBuilder, ObjectModule};
1010
use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
11+
use rustc_codegen_ssa::base::determine_cgu_reuse;
1112
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
1213
use rustc_data_structures::profiling::SelfProfilerRef;
1314
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -489,32 +490,3 @@ pub(crate) fn run_aot(
489490
concurrency_limiter,
490491
})
491492
}
492-
493-
// Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953
494-
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
495-
if !tcx.dep_graph.is_fully_enabled() {
496-
return CguReuse::No;
497-
}
498-
499-
let work_product_id = &cgu.work_product_id();
500-
if tcx.dep_graph.previous_work_product(work_product_id).is_none() {
501-
// We don't have anything cached for this CGU. This can happen
502-
// if the CGU did not exist in the previous session.
503-
return CguReuse::No;
504-
}
505-
506-
// Try to mark the CGU as green. If it we can do so, it means that nothing
507-
// affecting the LLVM module has changed and we can re-use a cached version.
508-
// If we compile with any kind of LTO, this means we can re-use the bitcode
509-
// of the Pre-LTO stage (possibly also the Post-LTO version but we'll only
510-
// know that later). If we are not doing LTO, there is only one optimized
511-
// version of each module, so we re-use that.
512-
let dep_node = cgu.codegen_dep_node(tcx);
513-
assert!(
514-
!tcx.dep_graph.dep_node_exists(&dep_node),
515-
"CompileCodegenUnit dep-node for CGU `{}` already exists before marking.",
516-
cgu.name()
517-
);
518-
519-
if tcx.try_mark_green(&dep_node) { CguReuse::PostLto } else { CguReuse::No }
520-
}

0 commit comments

Comments
 (0)