summary refs log tree commit diff
path: root/tests/codegen/intrinsics
AgeCommit message (Collapse)AuthorLines
2024-03-11Lower transmutes from int to pointer type as gep on nullBen Kimock-2/+2
2024-02-25Use generic `NonZero` in tests.Markus Reiter-3/+3
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-22/+22
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-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-0/+34
2023-07-27CHECK only for opaque ptrJosh Stone-2/+2
2023-07-27Update the minimum external LLVM to 15Josh Stone-4/+0
2023-07-08Always name the return place.Camille GILLOT-61/+57
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-27Also use `mir::Offset` for pointer `add`Scott McMurray-0/+34
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/+188
Fixes #109958
2023-04-09Handle not all immediates having `abi::Scalar`sScott McMurray-1/+92
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.
2023-01-17Add more codegen testsNilstrieb-4/+5
2023-01-17Put `noundef` on all scalars that don't allow uninitNilstrieb-2/+2
Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. This function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec. This is hopefully rare enough to not break anything.
2023-01-11Move /src/test to /testsAlbert Larsan-0/+328