about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/lower_intrinsics.rs
AgeCommit message (Collapse)AuthorLines
2025-06-29mir: Add a `new` method to `statement`dianqk-69/+66
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-2/+2
2025-05-30`slice.get(i)` should use a slice projection in MIR, like `slice[i]` doesScott McMurray-0/+46
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+11
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-01-23Disable non-required MIR opts with `optimize(none)`clubby789-0/+4
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-09-09Improve consistency in `LowerIntrinsics`.Nicholas Nethercote-62/+63
In some cases `target` and `arg` are obtained fallibly, and in some cases they are obtained infallibly. This commit changes them all to infallible.
2024-09-09Reduce visibilities, and add `warn(unreachable_pub)`.Nicholas Nethercote-1/+1
Lots of unnecessary `pub`s in this crate. Most are downgraded to `pub(super)`, though some don't need any visibility.
2024-09-03Move `MirPass` to `rustc_mir_transform`.Nicholas Nethercote-1/+1
Because that's now the only crate that uses it. Moving stuff out of `rustc_middle` is always welcome. I chose to use `impl crate::MirPass`/`impl crate::MirLint` (with explicit `crate::`) everywhere because that's the only mention of `MirPass`/`MirLint` used in all of these files. (Prior to this change, `MirPass` was mostly imported via `use rustc_middle::mir::*` items.)
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-21Save 2 pointers in `TerminatorKind` (96 → 80 bytes)Scott McMurray-38/+23
These things don't need to be `Vec`s; boxed slices are enough. The frequent one here is call arguments, but MIR building knows the number of arguments from the THIR, so the collect is always getting the allocation right in the first place, and thus this shouldn't ever add the shrink-in-place overhead.
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-0/+17
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-4/+4
2024-05-13Remove `extern crate rustc_middle` from `rustc_mir_transform`.Nicholas Nethercote-0/+1
2024-04-21Add an intrinsic that lowers to AggregateKind::RawPtrScott McMurray-0/+28
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-0/+2
2024-03-23refactor check_{lang,library}_ub: use a single intrinsic, put policy into ↵Ralf Jung-19/+2
library
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-2/+19
2024-03-04Return a struct from `query intrinsic` to be able to add another field in ↵Oli Scherer-5/+5
the next commit
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-2/+1
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+11
And in clippy
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-12/+12
To enable improved accuracy of diagnostics in upcoming commits.
2023-12-10remove redundant importssurechen-1/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-16Remove option_payload_ptr; redundant to offset_ofGeorge Bateman-32/+0
2023-10-13Format all the let chains in compilerMichael Goulet-12/+20
2023-10-09Simplify some mir passes by using let chainsDaniPopes-20/+5
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-2/+2
2023-09-06Don't report any errors in `lower_intrinsics`. They should have been ↵Oli Scherer-11/+1
typecked before.
2023-09-04read_via_copy: don't prematurely optimize away the readRalf Jung-12/+11
2023-08-03Forbid old-style `simd_shuffleN` intrinsicsOli Scherer-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-6/+7
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-1/+3
2023-06-19Promote unchecked_add/sub/mul/shl/shr to mir::BinOpScott McMurray-1/+11
2023-06-01Lower unchecked_{div, rem} to BinOp::{Div, Rem}Scott McMurray-23/+28
2023-05-08Rollup merge of #111004 - clubby789:migrate-mir-transform, r=oli-obkMichael Goulet-7/+3
Migrate `mir_transform` to translatable diagnostics cc #100717
2023-05-02Migrate `mir_transform` to translatable diagnosticsclubby789-7/+3
2023-04-30Codegen fewer instructions in `mem::replace`Scott McMurray-0/+23
2023-04-25Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray-0/+17
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-22Add `intrinsics::transmute_unchecked`Scott McMurray-1/+1
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`. Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions. It also simplifies a couple places in `core`.
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-2/+2
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+26
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-18move Option::as_slice to intrinsicAndre Bogus-0/+30
2023-03-14Improved implementation and comments after code review feedbackScott McMurray-13/+18
2023-03-11`MaybeUninit::assume_init_read` should have `noundef` load metadataScott McMurray-0/+24
I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Turned out to be a more general problem as `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. This PR lowers `ptr::read(p)` to `copy *p` in MIR, which fortuitiously also improves the IR we give to LLVM for things like `mem::replace`.
2023-02-18Replace _with_overflow instrinsics in LowerIntrinsics.Camille GILLOT-3/+23
2022-09-06Generalize the Assume intrinsic statement to a general Intrinsic statementOli Scherer-8/+16
2022-09-06Lower the assume intrinsic to a MIR statementOli Scherer-0/+11
2022-07-07Make MIR basic blocks field publicTomasz Miąsko-2/+2
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-1/+1
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-12/+12