Skip to content

Commit 4d4519a

Browse files
committed
Reuse determine_cgu_reuse from cg_ssa in cg_clif
1 parent 5282e5e commit 4d4519a

File tree

2 files changed

+2
-30
lines changed
  • compiler
    • rustc_codegen_cranelift/src/driver
    • rustc_codegen_ssa/src

2 files changed

+2
-30
lines changed

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::sync::Arc;
77
use std::thread::JoinHandle;
88

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

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ pub fn provide(providers: &mut Providers) {
994994
};
995995
}
996996

997-
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
997+
pub fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
998998
if !tcx.dep_graph.is_fully_enabled() {
999999
return CguReuse::No;
10001000
}

0 commit comments

Comments
 (0)