Skip to content

Commit 3e6abf0

Browse files
authored
Rollup merge of rust-lang#94505 - cuviper:mono-item-sort-local, r=michaelwoerister,davidtwco
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
2 parents 293fa7a + 6a838e4 commit 3e6abf0

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
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
)

src/test/codegen/debuginfo-generic-closure-env-names.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// of the enclosing functions don't get lost.
44
//
55
// Unfortunately, the order that debuginfo gets emitted into LLVM IR becomes a bit hard
6-
// to predict once async fns are involved.
6+
// to predict once async fns are involved, so DAG allows any order.
77
//
88
// Note that the test does not check async-fns when targeting MSVC because debuginfo for
99
// those does not follow the enum-fallback encoding yet and thus is incomplete.
@@ -27,24 +27,24 @@
2727
// CHECK: ![[generic_async_block_NAMESPACE:[0-9]+]] = !DINamespace(name: "generic_async_block"
2828

2929
// function_containing_closure<u32>()
30-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<u32>", scope: ![[function_containing_closure_NAMESPACE]]
31-
// MSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<u32>", scope: ![[function_containing_closure_NAMESPACE]]
30+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<u32>", scope: ![[function_containing_closure_NAMESPACE]]
31+
// MSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<u32>", scope: ![[function_containing_closure_NAMESPACE]]
3232

3333
// generic_async_function<Foo>()
34-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[generic_async_function_NAMESPACE]]
34+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[generic_async_function_NAMESPACE]]
3535

3636
// generic_async_function<u32>()
37-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}<u32>", scope: ![[generic_async_function_NAMESPACE]]
37+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}<u32>", scope: ![[generic_async_function_NAMESPACE]]
3838

3939
// generic_async_block<Foo>()
40-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_block_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[generic_async_block_NAMESPACE]]
40+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_block_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[generic_async_block_NAMESPACE]]
4141

4242
// generic_async_block<u32>()
43-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_block_env#0}<u32>", scope: ![[generic_async_block_NAMESPACE]]
43+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{async_block_env#0}<u32>", scope: ![[generic_async_block_NAMESPACE]]
4444

4545
// function_containing_closure<Foo>()
46-
// NONMSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
47-
// MSVC: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
46+
// NONMSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "{closure_env#0}<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
47+
// MSVC-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "closure_env$0<debuginfo_generic_closure_env_names::Foo>", scope: ![[function_containing_closure_NAMESPACE]]
4848

4949

5050
#![crate_type = "lib"]

0 commit comments

Comments
 (0)