mirror of https://github.com/rust-lang/rust.git
Remove all checks of `IntrinsicDef::must_be_overridden` except for the actual overrides in codegen
This commit is contained in:
parent
e91084180e
commit
a8f71cf289
|
@ -81,10 +81,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
|
|||
return library.kind.is_statically_included().then_some(def_id);
|
||||
}
|
||||
|
||||
if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Only consider nodes that actually have exported symbols.
|
||||
match tcx.def_kind(def_id) {
|
||||
DefKind::Fn | DefKind::Static { .. } => {}
|
||||
|
|
|
@ -1067,14 +1067,11 @@ fn should_encode_mir(
|
|||
// Full-fledged functions + closures
|
||||
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
let mut opt = tcx.sess.opts.unstable_opts.always_encode_mir
|
||||
let opt = tcx.sess.opts.unstable_opts.always_encode_mir
|
||||
|| (tcx.sess.opts.output_types.should_codegen()
|
||||
&& reachable_set.contains(&def_id)
|
||||
&& (generics.requires_monomorphization(tcx)
|
||||
|| tcx.cross_crate_inlinable(def_id)));
|
||||
if let Some(intrinsic) = tcx.intrinsic(def_id) {
|
||||
opt &= !intrinsic.must_be_overridden;
|
||||
}
|
||||
// The function has a `const` modifier or is in a `#[const_trait]`.
|
||||
let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
|
||||
|| tcx.is_const_default_method(def_id.to_def_id());
|
||||
|
@ -1704,10 +1701,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
{
|
||||
for &local_def_id in tcx.mir_keys(()) {
|
||||
if let DefKind::AssocFn | DefKind::Fn = tcx.def_kind(local_def_id) {
|
||||
if tcx.intrinsic(local_def_id).map_or(true, |i| !i.must_be_overridden) {
|
||||
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
|
||||
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
|
||||
}
|
||||
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
|
||||
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1365,9 +1365,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
|
|||
|
||||
fn visit_impl_item(&mut self, item: &'hir ImplItem<'hir>) {
|
||||
if associated_body(Node::ImplItem(item)).is_some() {
|
||||
if !self.tcx.has_attr(item.owner_id.def_id, sym::rustc_intrinsic_must_be_overridden) {
|
||||
self.body_owners.push(item.owner_id.def_id);
|
||||
}
|
||||
self.body_owners.push(item.owner_id.def_id);
|
||||
}
|
||||
|
||||
self.impl_items.push(item.impl_item_id());
|
||||
|
|
|
@ -1013,8 +1013,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
if let Some(source_scope) = scope {
|
||||
self.source_scope = source_scope;
|
||||
}
|
||||
|
||||
self.expr_into_dest(Place::return_place(), block, expr_id)
|
||||
if self.tcx.intrinsic(self.def_id).is_some_and(|i| i.must_be_overridden) {
|
||||
let source_info = self.source_info(rustc_span::DUMMY_SP);
|
||||
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
|
||||
self.cfg.start_new_block().unit()
|
||||
} else {
|
||||
self.expr_into_dest(Place::return_place(), block, expr_id)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_correct_source_scope_for_arg(
|
||||
|
|
|
@ -23,10 +23,6 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
|||
return false;
|
||||
}
|
||||
|
||||
if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This just reproduces the logic from Instance::requires_inline.
|
||||
match tcx.def_kind(def_id) {
|
||||
DefKind::Ctor(..) | DefKind::Closure => return true,
|
||||
|
|
|
@ -633,12 +633,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> &Body<'_> {
|
|||
}
|
||||
|
||||
fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
|
||||
if tcx.intrinsic(did).is_some_and(|i| i.must_be_overridden) {
|
||||
span_bug!(
|
||||
tcx.def_span(did),
|
||||
"this intrinsic must be overridden by the codegen backend, it has no meaningful body",
|
||||
)
|
||||
}
|
||||
if tcx.is_constructor(did.to_def_id()) {
|
||||
// There's no reason to run all of the MIR passes on constructors when
|
||||
// we can just output the MIR we want directly. This also saves const
|
||||
|
|
|
@ -1030,11 +1030,6 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
|
|||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if def_id.is_local() {
|
||||
// Local items cannot be referred to locally without monomorphizing them locally.
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue