From bf5fc6e5d7f1bd6e8012a57c5848c3b7271ae2b1 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 22 Feb 2024 14:47:35 +0000 Subject: [PATCH] Remove some depgraph edges on the HIR by invoking the intrinsic query instead of checking the attribute --- compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 3 +-- compiler/rustc_mir_transform/src/cross_crate_inline.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 4 ++-- compiler/rustc_monomorphize/src/collector.rs | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 347a968a303..bff7e43b8e4 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -16,7 +16,6 @@ use rustc_middle::ty::{self, SymbolName, TyCtxt}; use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; -use rustc_span::sym; use rustc_target::spec::{SanitizerSet, TlsModel}; pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel { @@ -82,7 +81,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap, def_id: LocalDefId) -> bool { return false; } - if tcx.has_attr(def_id, sym::rustc_intrinsic_must_be_overridden) { + if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) { return false; } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 37d087a4696..cd9b98e4f32 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -632,9 +632,9 @@ fn optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> &Body<'_> { } fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { - if let Some(attr) = tcx.get_attr(did, sym::rustc_intrinsic_must_be_overridden) { + if tcx.intrinsic(did).is_some_and(|i| i.must_be_overridden) { span_bug!( - attr.span, + tcx.def_span(did), "this intrinsic must be overridden by the codegen backend, it has no meaningful body", ) } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index b3a28b546d3..b0cb9fa517f 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1019,7 +1019,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> return false; } - if tcx.has_attr(def_id, sym::rustc_intrinsic_must_be_overridden) { + if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) { // These are implemented by backends directly and have no meaningful body. return false; }