Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ff12979

Browse files
committedMar 14, 2024·
Remove all checks of IntrinsicDef::must_be_overridden except for the actual overrides in codegen
1 parent 2d8c6ff commit ff12979

File tree

7 files changed

+11
-32
lines changed

7 files changed

+11
-32
lines changed
 

‎compiler/rustc_codegen_ssa/src/back/symbol_export.rs

-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
8181
return library.kind.is_statically_included().then_some(def_id);
8282
}
8383

84-
if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
85-
return None;
86-
}
87-
8884
// Only consider nodes that actually have exported symbols.
8985
match tcx.def_kind(def_id) {
9086
DefKind::Fn | DefKind::Static { .. } => {}

‎compiler/rustc_metadata/src/rmeta/encoder.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1067,14 +1067,11 @@ fn should_encode_mir(
10671067
// Full-fledged functions + closures
10681068
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
10691069
let generics = tcx.generics_of(def_id);
1070-
let mut opt = tcx.sess.opts.unstable_opts.always_encode_mir
1070+
let opt = tcx.sess.opts.unstable_opts.always_encode_mir
10711071
|| (tcx.sess.opts.output_types.should_codegen()
10721072
&& reachable_set.contains(&def_id)
10731073
&& (generics.requires_monomorphization(tcx)
10741074
|| tcx.cross_crate_inlinable(def_id)));
1075-
if let Some(intrinsic) = tcx.intrinsic(def_id) {
1076-
opt &= !intrinsic.must_be_overridden;
1077-
}
10781075
// The function has a `const` modifier or is in a `#[const_trait]`.
10791076
let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
10801077
|| tcx.is_const_default_method(def_id.to_def_id());
@@ -1704,10 +1701,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17041701
{
17051702
for &local_def_id in tcx.mir_keys(()) {
17061703
if let DefKind::AssocFn | DefKind::Fn = tcx.def_kind(local_def_id) {
1707-
if tcx.intrinsic(local_def_id).map_or(true, |i| !i.must_be_overridden) {
1708-
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
1709-
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
1710-
}
1704+
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
1705+
self.tcx.deduced_param_attrs(local_def_id.to_def_id()));
17111706
}
17121707
}
17131708
}

‎compiler/rustc_middle/src/hir/map/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1372,9 +1372,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
13721372

13731373
fn visit_impl_item(&mut self, item: &'hir ImplItem<'hir>) {
13741374
if associated_body(Node::ImplItem(item)).is_some() {
1375-
if !self.tcx.has_attr(item.owner_id.def_id, sym::rustc_intrinsic_must_be_overridden) {
1376-
self.body_owners.push(item.owner_id.def_id);
1377-
}
1375+
self.body_owners.push(item.owner_id.def_id);
13781376
}
13791377

13801378
self.impl_items.push(item.impl_item_id());

‎compiler/rustc_mir_build/src/build/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10061006
if let Some(source_scope) = scope {
10071007
self.source_scope = source_scope;
10081008
}
1009-
1010-
self.expr_into_dest(Place::return_place(), block, expr_id)
1009+
if self.tcx.intrinsic(self.def_id).is_some_and(|i| i.must_be_overridden) {
1010+
let source_info = self.source_info(rustc_span::DUMMY_SP);
1011+
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
1012+
self.cfg.start_new_block().unit()
1013+
} else {
1014+
self.expr_into_dest(Place::return_place(), block, expr_id)
1015+
}
10111016
}
10121017

10131018
fn set_correct_source_scope_for_arg(

‎compiler/rustc_mir_transform/src/cross_crate_inline.rs

-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
2323
return false;
2424
}
2525

26-
if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
27-
return false;
28-
}
29-
3026
// This just reproduces the logic from Instance::requires_inline.
3127
match tcx.def_kind(def_id) {
3228
DefKind::Ctor(..) | DefKind::Closure => return true,

‎compiler/rustc_mir_transform/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> &Body<'_> {
632632
}
633633

634634
fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
635-
if tcx.intrinsic(did).is_some_and(|i| i.must_be_overridden) {
636-
span_bug!(
637-
tcx.def_span(did),
638-
"this intrinsic must be overridden by the codegen backend, it has no meaningful body",
639-
)
640-
}
641635
if tcx.is_constructor(did.to_def_id()) {
642636
// There's no reason to run all of the MIR passes on constructors when
643637
// we can just output the MIR we want directly. This also saves const

‎compiler/rustc_monomorphize/src/collector.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1024,11 +1024,6 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
10241024
return false;
10251025
}
10261026

1027-
if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
1028-
// These are implemented by backends directly and have no meaningful body.
1029-
return false;
1030-
}
1031-
10321027
if def_id.is_local() {
10331028
// Local items cannot be referred to locally without monomorphizing them locally.
10341029
return true;

0 commit comments

Comments
 (0)
Please sign in to comment.