Skip to content

Commit 4d5b3b1

Browse files
committed
Auto merge of rust-lang#129239 - DianQK:codegen-rustc_intrinsic, r=saethlin
Don't generate functions with the `rustc_intrinsic_must_be_overridden` attribute Functions with the attribute `rustc_intrinsic_must_be_overridden` never be called. r? compiler
2 parents a971212 + 4508800 commit 4d5b3b1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/rustc_monomorphize/src/collector.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,9 @@ fn visit_instance_use<'tcx>(
888888
if tcx.should_codegen_locally(panic_instance) {
889889
output.push(create_fn_mono_item(tcx, panic_instance, source));
890890
}
891-
} else if tcx.has_attr(def_id, sym::rustc_intrinsic) {
891+
} else if tcx.has_attr(def_id, sym::rustc_intrinsic)
892+
&& !tcx.has_attr(def_id, sym::rustc_intrinsic_must_be_overridden)
893+
{
892894
// Codegen the fallback body of intrinsics with fallback bodies
893895
let instance = ty::Instance::new(def_id, instance.args);
894896
if tcx.should_codegen_locally(instance) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ revisions: OPT0 OPT1
2+
//@ [OPT0] compile-flags: -Copt-level=0
3+
//@ [OPT1] compile-flags: -Copt-level=1
4+
//@ compile-flags: -Cno-prepopulate-passes
5+
6+
#![crate_type = "lib"]
7+
#![feature(core_intrinsics)]
8+
9+
// CHECK-NOT: core::intrinsics::size_of_val
10+
11+
#[no_mangle]
12+
pub unsafe fn size_of_val(ptr: *const i32) -> usize {
13+
core::intrinsics::size_of_val(ptr)
14+
}

0 commit comments

Comments
 (0)