-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify intrinsics body handling in StableMIR #126361
Conversation
rust-lang#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI. The new mechanism introduces a placeholder body and mark the intrinsic with #[rustc_intrinsic_must_be_overridden]. In practice, this means that backends should not generate code for the placeholder, and shim the intrinsic. The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users. In this PR, intrinsics marked with `rustc_intrinsic_must_be_overridden` are handled the same way as intrinsics that do not have a body.
let must_override = if let Some(intrinsic) = self.tcx.intrinsic(def_id) { | ||
intrinsic.must_be_overridden | ||
} else { | ||
false | ||
}; | ||
!must_override && self.tcx.is_mir_available(def_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let must_override = if let Some(intrinsic) = self.tcx.intrinsic(def_id) { | |
intrinsic.must_be_overridden | |
} else { | |
false | |
}; | |
!must_override && self.tcx.is_mir_available(def_id) | |
if let Some(intrinsic) = self.tcx.intrinsic(def_id) { | |
!intrinsic.must_be_overridden | |
} else { | |
self.tcx.is_mir_available(def_id) | |
} |
the compiler guarantees than any !must_be_overridden
intrinsic has a body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work though. The test check_intrinsic
will ICE because size_of_val
doesn't have a body and must_be_overriden
is false.
thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:208:1:
DefId(2:1632 ~ core[8aa9]::intrinsics::{extern#1}::size_of_val) does not have a "optimized_mir"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right, we should probably automatically set that flag for bodyless intrinsics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you want me to
@bors r+ |
…li-obk Unify intrinsics body handling in StableMIR rust-lang#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI. The new mechanism introduces a placeholder body and mark the intrinsic with `#[rustc_intrinsic_must_be_overridden]`. In practice, this means that a backend should not generate code for the placeholder, and shim the intrinsic. The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users. In this PR, we unify the interface for intrinsics marked with `rustc_intrinsic_must_be_overridden` and intrinsics that do not have a body. Fixes rust-lang/project-stable-mir#79 r? `@oli-obk` cc: `@momvart`
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#125829 (rustc_span: Add conveniences for working with span formats) - rust-lang#126279 (Migrate `inaccessible-temp-dir`, `output-with-hyphens` and `issue-10971-temps-dir` `run-make` tests to `rmake`) - rust-lang#126361 (Unify intrinsics body handling in StableMIR) - rust-lang#126417 (Add `f16` and `f128` inline ASM support for `x86` and `x86-64`) - rust-lang#126424 ( Also sort `crt-static` in `--print target-features` output) - rust-lang#126428 (Polish `std::path::absolute` documentation.) - rust-lang#126429 (Add `f16` and `f128` const eval for binary and unary operationations) - rust-lang#126448 (End support for Python 3.8 in tidy) - rust-lang#126488 (Use `std::path::absolute` in bootstrap) - rust-lang#126511 (.mailmap: Associate both my work and my private email with me) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#125829 (rustc_span: Add conveniences for working with span formats) - rust-lang#126361 (Unify intrinsics body handling in StableMIR) - rust-lang#126417 (Add `f16` and `f128` inline ASM support for `x86` and `x86-64`) - rust-lang#126424 ( Also sort `crt-static` in `--print target-features` output) - rust-lang#126428 (Polish `std::path::absolute` documentation.) - rust-lang#126429 (Add `f16` and `f128` const eval for binary and unary operationations) - rust-lang#126448 (End support for Python 3.8 in tidy) - rust-lang#126488 (Use `std::path::absolute` in bootstrap) - rust-lang#126511 (.mailmap: Associate both my work and my private email with me) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#126361 - celinval:issue-0079-intrinsic, r=oli-obk Unify intrinsics body handling in StableMIR rust-lang#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI. The new mechanism introduces a placeholder body and mark the intrinsic with `#[rustc_intrinsic_must_be_overridden]`. In practice, this means that a backend should not generate code for the placeholder, and shim the intrinsic. The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users. In this PR, we unify the interface for intrinsics marked with `rustc_intrinsic_must_be_overridden` and intrinsics that do not have a body. Fixes rust-lang/project-stable-mir#79 r? ``@oli-obk`` cc: ``@momvart``
#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI.
The new mechanism introduces a placeholder body and mark the intrinsic with
#[rustc_intrinsic_must_be_overridden]
.In practice, this means that a backend should not generate code for the placeholder, and shim the intrinsic.
The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users.
In this PR, we unify the interface for intrinsics marked with
rustc_intrinsic_must_be_overridden
and intrinsics that do not have a body.Fixes rust-lang/project-stable-mir#79
r? @oli-obk
cc: @momvart