summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_interface/src/queries.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_interface/src/queries.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_interface/src/queries.rs')
-rw-r--r--compiler/rustc_interface/src/queries.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index c441a8ffd..8c4cdc669 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -5,6 +5,7 @@ use crate::passes;
use rustc_ast as ast;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::CodegenResults;
+use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{AppendOnlyIndexVec, Lrc, OnceCell, RwLock, WorkerLocal};
@@ -92,7 +93,6 @@ pub struct Queries<'tcx> {
dep_graph: Query<DepGraph>,
// This just points to what's in `gcx_cell`.
gcx: Query<&'tcx GlobalCtxt<'tcx>>,
- ongoing_codegen: Query<Box<dyn Any>>,
}
impl<'tcx> Queries<'tcx> {
@@ -109,14 +109,13 @@ impl<'tcx> Queries<'tcx> {
register_plugins: Default::default(),
dep_graph: Default::default(),
gcx: Default::default(),
- ongoing_codegen: Default::default(),
}
}
fn session(&self) -> &Lrc<Session> {
&self.compiler.sess
}
- fn codegen_backend(&self) -> &Lrc<Box<dyn CodegenBackend>> {
+ fn codegen_backend(&self) -> &Lrc<dyn CodegenBackend> {
self.compiler.codegen_backend()
}
@@ -193,9 +192,15 @@ impl<'tcx> Queries<'tcx> {
let future_opt = self.dep_graph_future()?.steal();
let dep_graph = future_opt
.and_then(|future| {
- let (prev_graph, prev_work_products) =
+ let (prev_graph, mut prev_work_products) =
sess.time("blocked_on_dep_graph_loading", || future.open().open(sess));
-
+ // Convert from UnordMap to FxIndexMap by sorting
+ let prev_work_product_ids =
+ prev_work_products.items().map(|x| *x.0).into_sorted_stable_ord();
+ let prev_work_products = prev_work_product_ids
+ .into_iter()
+ .map(|x| (x, prev_work_products.remove(&x).unwrap()))
+ .collect::<FxIndexMap<_, _>>();
rustc_incremental::build_dep_graph(sess, prev_graph, prev_work_products)
})
.unwrap_or_else(DepGraph::new_disabled);
@@ -242,23 +247,19 @@ impl<'tcx> Queries<'tcx> {
})
}
- pub fn ongoing_codegen(&'tcx self) -> Result<QueryResult<'_, Box<dyn Any>>> {
- self.ongoing_codegen.compute(|| {
- self.global_ctxt()?.enter(|tcx| {
- tcx.analysis(()).ok();
-
- // Don't do code generation if there were any errors
- self.session().compile_status()?;
+ pub fn ongoing_codegen(&'tcx self) -> Result<Box<dyn Any>> {
+ self.global_ctxt()?.enter(|tcx| {
+ // Don't do code generation if there were any errors
+ self.session().compile_status()?;
- // If we have any delayed bugs, for example because we created TyKind::Error earlier,
- // it's likely that codegen will only cause more ICEs, obscuring the original problem
- self.session().diagnostic().flush_delayed();
+ // If we have any delayed bugs, for example because we created TyKind::Error earlier,
+ // it's likely that codegen will only cause more ICEs, obscuring the original problem
+ self.session().diagnostic().flush_delayed();
- // Hook for UI tests.
- Self::check_for_rustc_errors_attr(tcx);
+ // Hook for UI tests.
+ Self::check_for_rustc_errors_attr(tcx);
- Ok(passes::start_codegen(&***self.codegen_backend(), tcx))
- })
+ Ok(passes::start_codegen(&**self.codegen_backend(), tcx))
})
}
@@ -296,7 +297,7 @@ impl<'tcx> Queries<'tcx> {
}
}
- pub fn linker(&'tcx self) -> Result<Linker> {
+ pub fn linker(&'tcx self, ongoing_codegen: Box<dyn Any>) -> Result<Linker> {
let sess = self.session().clone();
let codegen_backend = self.codegen_backend().clone();
@@ -307,7 +308,6 @@ impl<'tcx> Queries<'tcx> {
tcx.dep_graph.clone(),
)
});
- let ongoing_codegen = self.ongoing_codegen()?.steal();
Ok(Linker {
sess,
@@ -324,7 +324,7 @@ impl<'tcx> Queries<'tcx> {
pub struct Linker {
// compilation inputs
sess: Lrc<Session>,
- codegen_backend: Lrc<Box<dyn CodegenBackend>>,
+ codegen_backend: Lrc<dyn CodegenBackend>,
// compilation outputs
dep_graph: DepGraph,