about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir/place.rs
AgeCommit message (Collapse)AuthorLines
2025-09-26ProjectionElem::Subtype -> CastKind::Subtypebeepster4096-1/+0
2025-07-03Allow all MIR `Aggregate`s to take the operand path (if layout permits)Scott McMurray-46/+82
2025-06-03Change `tag_field` to `FieldIdx` in `Variants::Multiple`Scott McMurray-2/+2
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-03-12Don't `alloca` just to look at a discriminantScott McMurray-124/+0
Today we're making LLVM do a bunch of extra work for every enum you match on, even trivial stuff like `Option<bool>`. Let's not.
2025-03-07Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwcoMatthias Krüger-1/+1
Clean up various LLVM FFI things in codegen_llvm cc ```@ZuseZ4``` I touched some autodiff parts The major change of this PR is [bfd88ce](https://github.com/rust-lang/rust/pull/137549/commits/bfd88cead0dd79717f123ad7e9a26ecad88653cb) which makes `CodegenCx` generic just like `GenericBuilder` The other commits mostly took advantage of the new feature of making extern functions safe, but also just used some wrappers that were already there and shrunk unsafe blocks. best reviewed commit-by-commit
2025-02-24Remove an unnecessary lifetimeOli Scherer-1/+1
2025-02-24ssa/mono: deduplicate `type_has_metadata`David Wood-2/+6
The implementation of the `type_has_metadata` function is duplicated in `rustc_codegen_ssa` and `rustc_monomorphize`, so move this to `rustc_middle`.
2025-02-24Auto merge of #137271 - nikic:gep-nuw-2, r=scottmcmbors-1/+1
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes https://github.com/rust-lang/rust/issues/137217.
2025-02-19Also use gep inbounds nuw for index projectionsNikita Popov-1/+1
2025-02-19Remove `rustc_middle::mir::tcx` module.Nicholas Nethercote-1/+1
This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types.
2025-02-08Rustfmtbjorn3-4/+4
2025-01-31Implement MIR, CTFE, and codegen for unsafe bindersMichael Goulet-0/+3
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-4/+4
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-1/+2
2024-12-15Simplify the GEP instruction for indexDianQK-4/+1
2024-11-30use stores of the correct size to set discriminantsThe 8472-8/+16
2024-11-03compiler: Directly use rustc_abi in codegenJubilee Young-2/+1
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-3/+3
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-08compiler: Factor rustc_target::abi out of cg_ssaJubilee Young-3/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-9/+8
2024-09-17Rename supertraits of `CodegenMethods`.Nicholas Nethercote-1/+1
Supertraits of `BuilderMethods` are all called `XyzBuilderMethods`. Supertraits of `CodegenMethods` are all called `XyzMethods`. This commit changes the latter to `XyzCodegenMethods`, for consistency.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-20compiler: Never debug_assert in codegenJubilee Young-2/+2
The gains in performance are not worth the costs in correctness. This is partly because the gains are zero and the costs are unknown.
2024-07-02Use the aligned size for alloca at ret when the pass mode is cast.DianQK-1/+9
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-0/+5
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_codegen_ssa`.Nicholas Nethercote-5/+6
2024-05-10Refactoring after the `PlaceValue` additionScott McMurray-36/+51
I added `PlaceValue` in 123775, but kept that one line-by-line simple because it touched so many places. This goes through to add more helpers & docs, and change some `PlaceRef` to `PlaceValue` where the type didn't need to be included. No behaviour changes.
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-1/+1
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-11use [N x i8] for alloca typesErik Desjardins-1/+1
2024-04-11Add load/store helpers that take `PlaceValue`Scott McMurray-3/+2
2024-04-11Make `PlaceRef` hold a `PlaceValue` for the non-layout fields (like ↵Scott McMurray-30/+64
`OperandRef` does)
2024-03-04use GEP inbounds for ZST and DST field offsetsErik Desjardins-6/+1
For the former, it's fine for `inbounds` offsets to be one-past-the-end, so it's okay even if the ZST is the last field in the layout: > The base pointer has an in bounds address of an allocated object, > which means that it points into an allocated object, or to its end. https://llvm.org/docs/LangRef.html#getelementptr-instruction For the latter, even DST fields must always be inside the layout (or to its end for ZSTs), so using inbounds is also fine there.
2024-02-27use non-inbounds GEP for ZSTs, add fixmesErik Desjardins-0/+5
2024-02-26introduce and use ptradd/inbounds_ptradd instead of gepErik Desjardins-2/+2
2024-02-26always use gep inbounds i8 (ptradd) for field offsetsErik Desjardins-29/+5
2024-01-02Address review commentsNikita Popov-7/+5
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-2/+1
Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirement. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2023-12-12reject projecting to fields whose offset we cannot computeRalf Jung-12/+7
2023-12-12codegen: panic when trying to compute size/align of extern typeRalf Jung-2/+2
2023-12-03codegen, miri: fix computing the offset of an unsized field in a packed structRalf Jung-10/+12
2023-11-21Fix some unnecessary castsNilstrieb-7/+5
`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-10-02Add docs, remove code, change subtyper codeouz-a-1/+1
2023-10-02subtyping_projectionsouz-a-0/+1
2023-09-28Strip `OpaqueCast` during `RevealAll`.Oli Scherer-1/+3
2023-08-29const_eval and codegen: audit uses of is_zstRalf Jung-1/+2
2023-08-06cleanup misinformation regarding has_derefouz-a-1/+1
2023-07-29cg_ssa: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-34/+5
2023-07-10ensure byval allocas are sufficiently alignedErik Desjardins-2/+10
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-1/+1