Skip to content

Commit aac29d1

Browse files
committed
Auto merge of rust-lang#122010 - oli-obk:intrinsics3.0, r=pnkfelix
Avoid invoking the `intrinsic` query for DefKinds other than `Fn` or `AssocFn` fixes the perf regression from rust-lang#120675 by only invoking (and thus inserting into the dep graph) the `intrinsic` query if the `DefKind` matches items that can actually be intrinsics
2 parents 1b2c53a + b0f71f1 commit aac29d1

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ provide! { tcx, def_id, other, cdata,
356356
cdata.get_stability_implications(tcx).iter().copied().collect()
357357
}
358358
stripped_cfg_items => { cdata.get_stripped_cfg_items(cdata.cnum, tcx) }
359-
intrinsic => { cdata.get_intrinsic(def_id.index) }
359+
intrinsic_raw => { cdata.get_intrinsic(def_id.index) }
360360
defined_lang_items => { cdata.get_lang_items(tcx) }
361361
diagnostic_items => { cdata.get_diagnostic_items() }
362362
missing_lang_items => { cdata.get_missing_lang_items(tcx) }

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ rustc_queries! {
17451745
separate_provide_extern
17461746
}
17471747
/// Whether the function is an intrinsic
1748-
query intrinsic(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
1748+
query intrinsic_raw(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
17491749
desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) }
17501750
separate_provide_extern
17511751
}

compiler/rustc_middle/src/ty/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,14 @@ impl<'tcx> TyCtxt<'tcx> {
23342334
)
23352335
}
23362336

2337+
pub fn intrinsic(self, def_id: impl IntoQueryParam<DefId> + Copy) -> Option<ty::IntrinsicDef> {
2338+
match self.def_kind(def_id) {
2339+
DefKind::Fn | DefKind::AssocFn => {}
2340+
_ => return None,
2341+
}
2342+
self.intrinsic_raw(def_id)
2343+
}
2344+
23372345
pub fn local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> HirId {
23382346
self.opt_local_def_id_to_hir_id(local_def_id).unwrap()
23392347
}

compiler/rustc_middle/src/ty/util.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1642,11 +1642,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
16421642
}
16431643

16441644
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute)
1645-
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
1646-
match tcx.def_kind(def_id) {
1647-
DefKind::Fn | DefKind::AssocFn => {}
1648-
_ => return None,
1649-
}
1645+
pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
16501646
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
16511647
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
16521648
{
@@ -1664,7 +1660,7 @@ pub fn provide(providers: &mut Providers) {
16641660
reveal_opaque_types_in_bounds,
16651661
is_doc_hidden,
16661662
is_doc_notable_trait,
1667-
intrinsic,
1663+
intrinsic_raw,
16681664
..*providers
16691665
}
16701666
}

0 commit comments

Comments
 (0)