about summary refs log tree commit diff
path: root/tests/codegen/function-arguments.rs
AgeCommit message (Collapse)AuthorLines
2025-07-22Rename `tests/codegen` into `tests/codegen-llvm`Guillaume Gomez-278/+0
2025-07-01Remove support for dyn*Michael Goulet-9/+0
2025-02-11tests/codegen: use -Copt-level=3 instead of -OJubilee Young-1/+1
2025-01-30LLVM changed the nocapture attribute to captures(none)Hans Wennborg-2/+2
This updates RustWrapper.cpp and tests after https://github.com/llvm/llvm-project/pull/123181
2024-11-08pointee_info_at: fix logic for recursing into enumsRalf Jung-4/+20
2024-10-23Set `signext` or `zeroext` for integer arguments on RISC-VAsuna-4/+4
2024-08-11Add range attribute to scalar function results and argumentsAndreas Jonson-3/+3
2024-05-31Run rustfmt on `tests/codegen/`.Nicholas Nethercote-80/+52
Except for `simd-intrinsic/`, which has a lot of files containing multiple types like `u8x64` which really are better when hand-formatted. There is a surprising amount of two-space indenting in this directory. Non-trivial changes: - `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the test. - `rustfmt::skip` used in a few places where hand-formatting read more nicely: `enum/enum-match.rs` - Line number adjustments needed for the expected output of `debug-column.rs` and `coroutine-debug.rs`.
2024-04-25Auto merge of #121298 - nikic:writable, r=cuviperbors-1/+1
Set writable and dead_on_unwind attributes for sret arguments Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's. See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that: * The return slot is writable. * The return slot will not be read if the function unwinds. Fixes https://github.com/rust-lang/rust/issues/90595.
2024-04-25Set writable and dead_on_unwind attributes for sret argumentsNikita Popov-1/+1
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-03-11Auto merge of #122050 - erikdesjardins:sret, r=nikicbors-1/+1
Stop using LLVM struct types for byval/sret For `byval` and `sret`, the type has no semantic meaning, only the size matters\*†. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. \*: The alignment would matter, if we didn't explicitly specify it. From what I can tell, we always specified the alignment for `sret`; for `byval`, we didn't until #112157. †: For `byval`, the hidden copy may be impacted by padding in the LLVM struct type, i.e. padding bytes may not be copied. (I'm not sure if this is done today, but I think it would be legal.) But we manually pad our LLVM struct types specifically to avoid there ever being LLVM-visible padding, so that shouldn't be an issue. Split out from #121577. r? `@nikic`
2024-03-05use [N x i8] for byval/sret typesErik Desjardins-1/+1
This avoids depending on LLVM's struct types to determine the size of the byval/sret slot.
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+10
2024-02-25Use generic `NonZero` in tests.Markus Reiter-4/+4
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-1/+1
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-1/+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-07-27CHECK only for opaque ptrJosh Stone-32/+32
2023-07-10rustc_target: Add alignment to indirectly-passed by-value types, correcting thePatrick Walton-2/+2
alignment of `byval` on x86 in the process. Commit 88e4d2c2918428d55e34cd57c11279ea839c8822 from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by @eddyb. Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: https://github.com/rust-lang/rust/pull/80822#issuecomment-829985417
2023-07-08Always name the return place.Camille GILLOT-1/+1
2023-02-18Make dyn* have the same scalar pair ABI as corresponding fat pointerMichael Goulet-1/+3
2023-02-18Add codegen testMichael Goulet-0/+7
2023-02-06also do not add noalias on not-Unpin BoxRalf Jung-2/+8
2023-02-06make &mut !Unpin not dereferenceableRalf Jung-1/+15
See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 for discussion.
2023-01-17Add more codegen testsNilstrieb-1/+27
2023-01-17Put `noundef` on all scalars that don't allow uninitNilstrieb-15/+15
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/+235