Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d02ce7

Browse files
Rollup merge of #136118 - oli-obk:push-qsslxsopnrmr, r=Zalathar
Change `collect_and_partition_mono_items` tuple return type to a struct #133429 will add a new field to this tuple, so it seems prudent to turn it into a struct first to avoid confusion about what the tuple elements mean.
2 parents 03fdcff + b24f674 commit 3d02ce7

File tree

9 files changed

+33
-21
lines changed

9 files changed

+33
-21
lines changed

‎compiler/rustc_codegen_cranelift/src/driver/aot.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ pub(crate) fn run_aot(
676676
.to_owned();
677677

678678
let cgus = if tcx.sess.opts.output_types.should_codegen() {
679-
tcx.collect_and_partition_mono_items(()).1
679+
tcx.collect_and_partition_mono_items(()).codegen_units
680680
} else {
681681
// If only `--emit metadata` is used, we shouldn't perform any codegen.
682682
// Also `tcx.collect_and_partition_mono_items` may panic in that case.

‎compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_index::IndexVec;
1111
use rustc_middle::mir;
12+
use rustc_middle::mir::mono::MonoItemPartitions;
1213
use rustc_middle::ty::{self, TyCtxt};
1314
use rustc_session::RemapFileNameExt;
1415
use rustc_session::config::RemapPathScopeComponents;
@@ -297,12 +298,13 @@ struct UsageSets<'tcx> {
297298
/// Prepare sets of definitions that are relevant to deciding whether something
298299
/// is an "unused function" for coverage purposes.
299300
fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> {
300-
let (all_mono_items, cgus) = tcx.collect_and_partition_mono_items(());
301+
let MonoItemPartitions { all_mono_items, codegen_units } =
302+
tcx.collect_and_partition_mono_items(());
301303

302304
// Obtain a MIR body for each function participating in codegen, via an
303305
// arbitrary instance.
304306
let mut def_ids_seen = FxHashSet::default();
305-
let def_and_mir_for_all_mono_fns = cgus
307+
let def_and_mir_for_all_mono_fns = codegen_units
306308
.iter()
307309
.flat_map(|cgu| cgu.items().keys())
308310
.filter_map(|item| match item {

‎compiler/rustc_codegen_ssa/src/assert_module_sources.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTr
4646
return;
4747
}
4848

49-
let available_cgus =
50-
tcx.collect_and_partition_mono_items(()).1.iter().map(|cgu| cgu.name()).collect();
49+
let available_cgus = tcx
50+
.collect_and_partition_mono_items(())
51+
.codegen_units
52+
.iter()
53+
.map(|cgu| cgu.name())
54+
.collect();
5155

5256
let mut ams = AssertModuleSource {
5357
tcx,

‎compiler/rustc_codegen_ssa/src/back/symbol_export.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn exported_symbols_provider_local(
293293
// external linkage is enough for monomorphization to be linked to.
294294
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;
295295

296-
let (_,cgus) = tcx.collect_and_partition_mono_items(());
296+
let cgus = tcx.collect_and_partition_mono_items(()).codegen_units;
297297

298298
// The symbols created in this loop are sorted below it
299299
#[allow(rustc::potential_query_instability)]

‎compiler/rustc_codegen_ssa/src/base.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
619619

620620
// Run the monomorphization collector and partition the collected items into
621621
// codegen units.
622-
let codegen_units = tcx.collect_and_partition_mono_items(()).1;
622+
let codegen_units = tcx.collect_and_partition_mono_items(()).codegen_units;
623623

624624
// Force all codegen_unit queries so they are already either red or green
625625
// when compile_codegen_unit accesses them. We are not able to re-execute
@@ -1051,7 +1051,7 @@ pub(crate) fn provide(providers: &mut Providers) {
10511051
config::OptLevel::SizeMin => config::OptLevel::Default,
10521052
};
10531053

1054-
let (defids, _)= tcx.collect_and_partition_mono_items(cratenum);
1054+
let defids= tcx.collect_and_partition_mono_items(cratenum).all_mono_items;
10551055

10561056
let any_for_speed = defids.items().any(|id| {
10571057
let CodegenFnAttrs { optimize, .. } = tcx.codegen_fn_attrs(*id);

‎compiler/rustc_middle/src/mir/mono.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_data_structures::fx::FxIndexMap;
88
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher, ToStableHashKey};
99
use rustc_data_structures::unord::UnordMap;
1010
use rustc_hir::ItemId;
11-
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
11+
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet,LOCAL_CRATE};
1212
use rustc_index::Idx;
1313
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
1414
use rustc_query_system::ich::StableHashingContext;
@@ -247,6 +247,12 @@ impl ToStableHashKey<StableHashingContext<'_>> for MonoItem<'_> {
247247
}
248248
}
249249

250+
#[derive(Debug, HashStable, Copy, Clone)]
251+
pub struct MonoItemPartitions<'tcx> {
252+
pub codegen_units: &'tcx [CodegenUnit<'tcx>],
253+
pub all_mono_items: &'tcx DefIdSet,
254+
}
255+
250256
#[derive(Debug, HashStable)]
251257
pub struct CodegenUnit<'tcx> {
252258
/// A name for this CGU. Incremental compilation requires that

‎compiler/rustc_middle/src/query/erase.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ tcx_lifetime! {
349349
rustc_middle::mir::interpret::GlobalId,
350350
rustc_middle::mir::interpret::LitToConstInput,
351351
rustc_middle::mir::interpret::EvalStaticInitializerRawResult,
352+
rustc_middle::mir::mono::MonoItemPartitions,
352353
rustc_middle::traits::query::MethodAutoderefStepsResult,
353354
rustc_middle::traits::query::type_op::AscribeUserType,
354355
rustc_middle::traits::query::type_op::Eq,

‎compiler/rustc_middle/src/query/mod.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet};
2323
use rustc_errors::ErrorGuaranteed;
2424
use rustc_hir::def::{DefKind, DocLinkResMap};
2525
use rustc_hir::def_id::{
26-
CrateNum, DefId, DefIdMap, DefIdSet,LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
26+
CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
2727
};
2828
use rustc_hir::lang_items::{LangItem, LanguageItems};
2929
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
@@ -58,7 +58,7 @@ use crate::mir::interpret::{
5858
EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult,
5959
EvalToValTreeResult, GlobalId, LitToConstInput,
6060
};
61-
use crate::mir::mono::{CodegenUnit, CollectionMode, MonoItem};
61+
use crate::mir::mono::{CodegenUnit, CollectionMode, MonoItem,MonoItemPartitions};
6262
use crate::query::erase::{Erase, erase, restore};
6363
use crate::query::plumbing::{
6464
CyclePlaceholder, DynamicQuery, query_ensure, query_ensure_error_guaranteed, query_get_at,
@@ -2166,7 +2166,7 @@ rustc_queries! {
21662166
separate_provide_extern
21672167
}
21682168

2169-
query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet,&'tcx [CodegenUnit<'tcx>]) {
2169+
query collect_and_partition_mono_items(_: ()) -> MonoItemPartitions<'tcx> {
21702170
eval_always
21712171
desc { "collect_and_partition_mono_items" }
21722172
}

‎compiler/rustc_monomorphize/src/partitioning.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
110110
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
111111
use rustc_middle::mir::mono::{
112112
CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, MonoItem, MonoItemData,
113-
Visibility,
113+
MonoItemPartitions,Visibility,
114114
};
115115
use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths};
116116
use rustc_middle::ty::{self, InstanceKind, TyCtxt};
@@ -1114,7 +1114,7 @@ where
11141114
}
11151115
}
11161116

1117-
fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet,&[CodegenUnit<'_>]) {
1117+
fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitions<'_> {
11181118
let collection_strategy = match tcx.sess.opts.unstable_opts.print_mono_items {
11191119
Some(ref s) => {
11201120
let mode = s.to_lowercase();
@@ -1236,7 +1236,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
12361236
}
12371237
}
12381238

1239-
(tcx.arena.alloc(mono_items), codegen_units)
1239+
MonoItemPartitions{all_mono_items:tcx.arena.alloc(mono_items), codegen_units}
12401240
}
12411241

12421242
/// Outputs stats about instantiation counts and estimated size, per `MonoItem`'s
@@ -1319,14 +1319,13 @@ fn dump_mono_items_stats<'tcx>(
13191319
pub(crate) fn provide(providers: &mut Providers) {
13201320
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
13211321

1322-
providers.is_codegened_item = |tcx, def_id| {
1323-
let (all_mono_items, _) = tcx.collect_and_partition_mono_items(());
1324-
all_mono_items.contains(&def_id)
1325-
};
1322+
providers.is_codegened_item =
1323+
|tcx, def_id| tcx.collect_and_partition_mono_items(()).all_mono_items.contains(&def_id);
13261324

13271325
providers.codegen_unit = |tcx, name| {
1328-
let (_, all) = tcx.collect_and_partition_mono_items(());
1329-
all.iter()
1326+
tcx.collect_and_partition_mono_items(())
1327+
.codegen_units
1328+
.iter()
13301329
.find(|cgu| cgu.name() == name)
13311330
.unwrap_or_else(|| panic!("failed to find cgu with name {name:?}"))
13321331
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /