about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/abi.rs
AgeCommit message (Collapse)AuthorLines
2025-08-20Tell LLVM about read-only capturesNikita Popov-0/+1
`&Freeze` parameters are not only `readonly` within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the `captures(address, read_provenance)` attribute.
2025-08-06Fix ICEbjorn3-3/+6
2025-08-06Avoid using unadjusted ABI for the thread-local shimbjorn3-1/+1
This restricts the uses of the unadjusted ABI to LLVM intrinsics. The Rust ABI works fine for the thread-local shim as it always returns pointers directly like the backend expects.
2025-08-06Change adjust_for_rust_scalar into arg_attrs_for_rust_scalarbjorn3-16/+9
Directly creating the ArgAttributes rather than adjusting one is a bit clearer.
2025-07-28use let chains in mir, resolve, targetKivooeo-5/+5
2025-06-14Remove all support for wasm's legacy ABIbjorn3-18/+8
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-6/+7
2025-06-03compiler: change Conv to CanonAbiJubilee Young-41/+3
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-2/+4
async_drop_in_place::{closure}, scoped async drop added.
2025-04-07mitigate MSVC unsoundness by not emitting alignment attributes on win32-msvc ↵Ralf Jung-1/+2
targets also mention the MSVC alignment issue in platform-support.md
2025-04-06remove compiler support for `extern "rust-intrinsic"` blocksSkgland-2/+2
2025-03-18Remove existing AFIDT implementationMichael Goulet-25/+0
2025-03-04compiler: use `is_rustic_abi` in ty_utilsJubilee Young-5/+2
expands some conditionals to include different "rustic" ABIs, so that we actually handle passing args through all "rustic" ABIs
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-1/+1
2025-02-27Don't infer unwinding of virtual calls based on the function attributesDianQK-6/+13
2025-02-27Don't infer attributes of virtual calls based on the function bodyDianQK-34/+29
2025-02-20Update check to reflect that non-ZST uninhabited types should not be ↵Zachary S-1/+1
PassMode::Ignore.
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-3/+1
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-13Auto merge of #136954 - jhpratt:rollup-koefsot, r=jhprattbors-1/+1
Rollup of 12 pull requests Successful merges: - #134090 (Stabilize target_feature_11) - #135025 (Cast allocas to default address space) - #135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0) - #136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly) - #136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - #136806 (Fix cycle when debug-printing opaque types from RPITIT) - #136807 (compiler: internally merge `PtxKernel` into `GpuKernel`) - #136818 (Implement `read*_exact` for `std:io::repeat`) - #136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint) - #136937 (Update books) - #136945 (Add diagnostic item for `std::io::BufRead`) - #136947 (Reinstate nnethercote in the review rotation.) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-12Rollup merge of #136807 - ↵Jacob Pratt-1/+1
workingjubilee:merge-gpus-to-get-the-arcradeongeforce, r=bjorn3 compiler: internally merge `PtxKernel` into `GpuKernel` r? ``@bjorn3`` for review
2025-02-12Auto merge of #135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obkbors-1/+1
Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424. r? `@Noratrieb`
2025-02-10compiler: die immediately instead of handling unknown target codegenJubilee Young-8/+4
We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates.
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-1/+1
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-09compiler: internally merge `Conv::PtxKernel` into `GpuKernel`Jubilee Young-1/+1
It is speculated that these two can be conceptually merged, and it can start by ripping out rustc's notion of the PtxKernel call convention. Leave the ExternAbi for now, but the nvptx target now should see it as just a different way to spell Conv::GpuKernel.
2025-01-26Avoid using make_direct_deprecated() in extern "ptx-kernel"bjorn3-8/+3
This method will be removed in the future as it produces a broken ABI that depends on cg_llvm implementation details. After this PR wasm32-unknown-unknown is the only remaining user of make_direct_deprecated().
2025-01-16Add gpu-kernel calling conventionFlakebi-0/+1
The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.
2024-12-10Implement projection and shim for AFIDTMichael Goulet-0/+26
2024-12-06Remove polymorphizationBen Kimock-17/+2
2024-12-06Only allow PassMode::Direct for aggregates on wasm when using the C ABIbjorn3-10/+20
For the Rust ABI we don't have any ABI compat reasons to allow PassMode::Direct for aggregates.
2024-12-04fn_sig_for_fn_abi should return a ty::FnSig, no need for a binderMichael Goulet-80/+50
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-1/+1
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-18/+20
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-07Make fn_abi_sanity_check a bit stricterbjorn3-30/+51
The Rust ABI must ignore all ZST arguments, all ignored arguments must be either ZST or uninhabited. And finally ScalarPair should never be passed as PassMode::Direct.
2024-11-04ty::BrK -> ty::BoundRegionKind::KMichael Goulet-10/+12
2024-11-03compiler: Directly use rustc_abi in ty_utilsJubilee Young-15/+14
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-7/+7
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-23Introduce `adjust_for_rust_abi` in `rustc_target`Asuna-130/+8
2024-10-20x86-32 float return for 'Rust' ABI: treat all float types consistentlyRalf Jung-22/+15
2024-10-19Auto merge of #131211 - bjorn3:rust_abi_follow_c_rules, r=nikic,jieyouxubors-0/+43
Return values larger than 2 registers using a return area pointer LLVM and Cranelift disagree about how to return values that don't fit in the registers designated for return values. LLVM will force the entire return value to be passed by return area pointer, while Cranelift will look at each IR level return value independently and decide to pass it in a register or not, which would result in the return value being passed partially in registers and partially through a return area pointer. While Cranelift may need to be fixed as the LLVM behavior is generally more correct with respect to the surface language, forcing this behavior in rustc itself makes it easier for other backends to conform to the Rust ABI and for the C ABI rustc already handles this behavior anyway. In addition LLVM's decision to pass the return value in registers or using a return area pointer depends on how exactly the return type is lowered to an LLVM IR type. For example `Option<u128>` can be lowered as `{ i128, i128 }` in which case the x86_64 backend would use a return area pointer, or it could be passed as `{ i32, i128 }` in which case the x86_64 backend would pass it in registers by taking advantage of an LLVM ABI extension that allows using 3 registers for the x86_64 sysv call conv rather than the officially specified 2 registers. This adjustment is only necessary for the Rust ABI as for other ABI's the calling convention implementations in rustc_target already ensure any return value which doesn't fit in the available amount of return registers is passed in the right way for the current target. Helps with https://github.com/rust-lang/rustc_codegen_cranelift/issues/1525 cc https://github.com/bytecodealliance/wasmtime/issues/9250
2024-10-11rename RcBox in other places tooJonathan Dönszelmann-3/+3
2024-10-10Return values larger than 2 registers using a return area pointerbjorn3-0/+43
LLVM and Cranelift disagree about how to return values that don't fit in the registers designated for return values. LLVM will force the entire return value to be passed by return area pointer, while Cranelift will look at each IR level return value independently and decide to pass it in a register or not, which would result in the return value being passed partially in registers and partially through a return area pointer. While Cranelift may need to be fixed as the LLVM behavior is generally more correct with respect to the surface language, forcing this behavior in rustc itself makes it easier for other backends to conform to the Rust ABI and for the C ABI rustc already handles this behavior anyway. In addition LLVM's decision to pass the return value in registers or using a return area pointer depends on how exactly the return type is lowered to an LLVM IR type. For example `Option<u128>` can be lowered as `{ i128, i128 }` in which case the x86_64 backend would use a return area pointer, or it could be passed as `{ i32, i128 }` in which case the x86_64 backend would pass it in registers by taking advantage of an LLVM ABI extension that allows using 3 registers for the x86_64 sysv call conv rather than the officially specified 2 registers. This adjustment is only necessary for the Rust ABI as for other ABI's the calling convention implementations in rustc_target already ensure any return value which doesn't fit in the available amount of return registers is passed in the right way for the current target.
2024-10-08compiler: Factor rustc_target::abi::* out of ty_utilsJubilee Young-1/+3
2024-10-04Use wide pointers consistenly across the compilerUrgau-7/+7
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-21add `C-cmse-nonsecure-entry` ABIFolkert de Vries-0/+1
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-22/+26
2024-09-16make `LayoutCx` not genericLukas Markeffsky-5/+5
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-33/+0
closures
2024-08-18Auto merge of #125854 - beetrees:zst-arg-abi, r=estebankbors-25/+2
Move ZST ABI handling to `rustc_target` Currently, target specific handling of ZST function call ABI (specifically passing them indirectly instead of ignoring them) is handled in `rustc_ty_utils`, whereas all other target specific function call ABI handling is located in `rustc_target`. This PR moves the ZST handling to `rustc_target` so that all the target-specific function call ABI handling is in one place. In the process of doing so, this PR fixes #125850 by ensuring that ZST arguments are always correctly ignored in the x86-64 `"sysv64"` ABI; any code which would be affected by this fix would have ICEd before this PR. Tests are also added using `#[rustc_abi(debug)]` to ensure this behaviour does not regress. Fixes #125850
2024-08-13Use is_lang_item moreMichael Goulet-1/+1