diff options
| author | bors <bors@rust-lang.org> | 2023-09-09 09:08:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-09 09:08:54 +0000 |
| commit | 38bbc2ce03a2369d96898d58cc0aa06f1a4b5dcf (patch) | |
| tree | a92c25661a032851dfabaa2cadb833a2a5ea3cd3 | |
| parent | 5ede9408945b46ab183dd228253297bdf62304f7 (diff) | |
| parent | 2a5121b131bf311e4c0be89b4ce1e3e38f3e92da (diff) | |
| download | rust-38bbc2ce03a2369d96898d58cc0aa06f1a4b5dcf.tar.gz rust-38bbc2ce03a2369d96898d58cc0aa06f1a4b5dcf.zip | |
Auto merge of #115657 - Zoxc:source-span-avoid-query, r=cjgillot
Avoid a `source_span` query when encoding Spans into query results This avoids a `source_span` query when encoding `Span`s into query results. It's not sound to execute queries here as the query caches can be locked and the dep graph is no longer writable. r? `@cjgillot`
| -rw-r--r-- | compiler/rustc_incremental/src/persist/save.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/on_disk_cache.rs | 2 |
2 files changed, 15 insertions, 13 deletions
diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs index 0cfaf583774..7719482890e 100644 --- a/compiler/rustc_incremental/src/persist/save.rs +++ b/compiler/rustc_incremental/src/persist/save.rs @@ -48,18 +48,6 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) { join( move || { - sess.time("incr_comp_persist_result_cache", || { - // Drop the memory map so that we can remove the file and write to it. - if let Some(odc) = &tcx.query_system.on_disk_cache { - odc.drop_serialized_data(tcx); - } - - file_format::save_in(sess, query_cache_path, "query cache", |e| { - encode_query_cache(tcx, e) - }); - }); - }, - move || { sess.time("incr_comp_persist_dep_graph", || { if let Err(err) = tcx.dep_graph.encode(&tcx.sess.prof) { sess.emit_err(errors::WriteDepGraph { path: &staging_dep_graph_path, err }); @@ -73,6 +61,20 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) { } }); }, + move || { + // We execute this after `incr_comp_persist_dep_graph` for the serial compiler + // to catch any potential query execution writing to the dep graph. + sess.time("incr_comp_persist_result_cache", || { + // Drop the memory map so that we can remove the file and write to it. + if let Some(odc) = &tcx.query_system.on_disk_cache { + odc.drop_serialized_data(tcx); + } + + file_format::save_in(sess, query_cache_path, "query cache", |e| { + encode_query_cache(tcx, e) + }); + }); + }, ); }) } diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 154c930dc0f..280f5d0a84c 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -896,7 +896,7 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for Span { } if let Some(parent) = span_data.parent { - let enclosing = s.tcx.source_span(parent).data_untracked(); + let enclosing = s.tcx.source_span_untracked(parent).data_untracked(); if enclosing.contains(span_data) { TAG_RELATIVE_SPAN.encode(s); (span_data.lo - enclosing.lo).to_u32().encode(s); |
