about summary refs log tree commit diff
path: root/tests/codegen/intrinsics/transmute.rs
AgeCommit message (Collapse)AuthorLines
2025-07-22Rename `tests/codegen` into `tests/codegen-llvm`Guillaume Gomez-497/+0
2025-07-10Add `BuilderMethods::unreachable_nonterminator`Scott McMurray-21/+20
So places that need `unreachable` but in the middle of a basic block can call that instead of figuring out the best way to do it.
2025-07-09Make UB transmutes really UB in LLVMScott McMurray-9/+13
Ralf suggested in <https://github.com/rust-lang/rust/pull/143410#discussion_r2184928123> that UB transmutes shouldn't be trapping, which happened for the one path that PR was changing, but there's another path as well, so this PR changes that other path to match.
2025-07-04Address PR feedbackScott McMurray-7/+7
2025-04-05Update the minimum external LLVM to 19Josh Stone-7/+4
2025-02-23Don't re-`assume` in `transmute`s that don't change nichesScott McMurray-0/+25
2025-02-19Emit `trunc nuw` for unchecked shifts and `to_immediate_scalar`Scott McMurray-4/+7
- For shifts this shrinks the IR by no longer needing an `assume` while still providing the UB information - Having this on the `i8`→`i1` truncations will hopefully help with some places that have to load `i8`s or pass those in LLVM structs without range information
2025-02-12`transmute` should also assume non-null pointersScott McMurray-3/+5
Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-11tests/codegen: use -Copt-level=3 instead of -OJubilee Young-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-04-24Fix tests and blessGary Guo-1/+0
2024-04-11use [N x i8] for alloca typesErik Desjardins-8/+8
2024-03-11Lower transmutes from int to pointer type as gep on nullBen Kimock-2/+2
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-2/+2
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-5/+5
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-07-27Update the minimum external LLVM to 15Josh Stone-1/+0
2023-07-08Always name the return place.Camille GILLOT-47/+43
2023-05-31Add a distinct `OperandValue::ZeroSized` variant for ZSTsScott McMurray-4/+71
These tend to have special handling in a bunch of places anyway, so the variant helps remember that. And I think it's easier to grok than non-Scalar Aggregates sometimes being `Immediates` (like I got wrong and caused 109992). As a minor bonus, it means we don't need to generate poison LLVM values for them to pass around in `OperandValue::Immediate`s.
2023-04-22Add `intrinsics::transmute_unchecked`Scott McMurray-33/+9
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-04-13`assume` value ranges in `transmute`Scott McMurray-4/+4
Fixes #109958
2023-04-09Handle not all immediates having `abi::Scalar`sScott McMurray-1/+57
2023-04-06Check `CastKind::Transmute` sizes in a better wayScott McMurray-1/+73
Fixes #110005
2023-04-04Allow `transmute`s to produce `OperandValue`s instead of always using `alloca`sScott McMurray-23/+130
LLVM can usually optimize these away, but especially for things like transmutes of newtypes it's silly to generate the `alloc`+`store`+`load` at all when it's actually a nop at LLVM level.
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+196
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.