Skip to content

Commit 723d334

Browse files
committed
Restore the local filter on mono item sorting
In `CodegenUnit::items_in_deterministic_order`, there's a comment that only local HirIds should be taken into account, but rust-lang#90408 removed the `as_local` call that sets others to None. Restoring that check fixes the s390x hangs seen in [RHBZ 2058803]. [RHBZ 2058803]: https://bugzilla.redhat.com/show_bug.cgi?id=2058803
1 parent f0c4da4 commit 723d334

File tree

1 file changed

+4
-5
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+4
-5
lines changed

compiler/rustc_middle/src/mir/mono.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_data_structures::fx::FxHashMap;
77
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
88
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
99
use rustc_hir::ItemId;
10+
use rustc_index::vec::Idx;
1011
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
1112
use rustc_session::config::OptLevel;
1213
use rustc_span::source_map::Span;
@@ -380,7 +381,7 @@ impl<'tcx> CodegenUnit<'tcx> {
380381
// instances into account. The others don't matter for
381382
// the codegen tests and can even make item order
382383
// unstable.
383-
InstanceDef::Item(def) => Some(def.did.index.as_usize()),
384+
InstanceDef::Item(def) => def.did.as_local().map(Idx::index),
384385
InstanceDef::VtableShim(..)
385386
| InstanceDef::ReifyShim(..)
386387
| InstanceDef::Intrinsic(..)
@@ -391,10 +392,8 @@ impl<'tcx> CodegenUnit<'tcx> {
391392
| InstanceDef::CloneShim(..) => None,
392393
}
393394
}
394-
MonoItem::Static(def_id) => Some(def_id.index.as_usize()),
395-
MonoItem::GlobalAsm(item_id) => {
396-
Some(item_id.def_id.to_def_id().index.as_usize())
397-
}
395+
MonoItem::Static(def_id) => def_id.as_local().map(Idx::index),
396+
MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.index()),
398397
},
399398
item.symbol_name(tcx),
400399
)

0 commit comments

Comments
 (0)