about summary refs log tree commit diff
path: root/compiler/rustc_abi
AgeCommit message (Collapse)AuthorLines
2025-01-17Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubileebors-13/+22
Add gpu-kernel calling convention The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 (#120495 and https://github.com/rust-lang/rust-analyzer/pull/16463) 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. Tracking issue: #135467 amdgpu target tracking issue: #135024
2025-01-16Add gpu-kernel calling conventionFlakebi-13/+22
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.
2025-01-10fix ZST handling for Windows ABIs on MSVC targetRalf Jung-0/+4
2025-01-10exclude unsizable tail from randomization seed calculationThe 8472-13/+9
2025-01-10Foo<T> != Foo<U> under layout randomizationThe 8472-2/+74
previously field ordering was using the same seed for all instances of Foo, now we pass seed values through the layout tree so that not only the struct itself affects layout but also its fields
2024-12-30compiler: Add a statement-of-intent to `rustc_abi`Jubilee Young-0/+32
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-14/+17
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-11/+11
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-01fix safe-transmute handling of enumsRalf Jung-1/+5
2024-11-30improve TagEncoding::Niche docs and sanity checkRalf Jung-5/+19
2024-11-22Auto merge of #130867 - michirakara:steps_between, r=dtolnaybors-1/+1
distinguish overflow and unimplemented in Step::steps_between
2024-11-21distinguish overflow and unimplemented in Step::steps_betweenmichirakara-1/+1
2024-11-14Support s390x z13 vector ABITaiki Endo-0/+18
2024-11-08pointee_info_at: fix logic for recursing into enumsRalf Jung-4/+12
2024-10-30compiler: Lift `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`Jubilee Young-0/+376
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-111/+133
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-28Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errorsJubilee-2/+7
Add `LayoutS::is_uninhabited` and use it Use accessors for the things that accessors are good at: reducing everyone's need to be nosy and peek at the internals of every data structure.
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-2/+7
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-27compiler: Rename LayoutS to LayoutDataJubilee Young-33/+33
The last {UninternedType}S is in captivity. The galaxy is at peace.
2024-10-21Make rustc_abi compile on stable againLukas Wirth-15/+23
2024-10-20compiler: Reject impossible reprs during enum layoutJubilee Young-0/+9
2024-10-19compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`Jubilee Young-1/+26
2024-10-11compiler: Wire `{TyAnd,}Layout` into `rustc_abi`Jubilee Young-4/+266
This finally unites TyAndLayout, Layout, and LayoutS into the same crate, as one might imagine they would be placed. No functional changes.
2024-10-11compiler: Empty out rustc_target::abiJubilee Young-0/+269
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-8/+5
2024-09-21Auto merge of #127546 - workingjubilee:5-level-paging-exists, r=saethlinbors-6/+4
Correct outdated object size limit The comment here about 48 bit addresses being enough was written in 2016 but was made incorrect in 2019 by 5-level paging, and then persisted for another 5 years before being noticed and corrected. The bolding of the "exclusive" part is merely to call attention to something I missed when reading it and doublechecking the math. try-job: i686-msvc try-job: test-various
2024-09-21compiler: Precisely name units of object sizeJubilee-3/+3
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-09-20compiler: reuse {un,}signed_fit in get_type_suggestion (nfc)Jubilee Young-0/+22
no need for a weird macro when a self-explanatory `match` will do.
2024-09-19Correct outdated object size limitJubilee Young-6/+4
The comment here about 48 bit addresses being enough was written in 2016 but was made incorrect in 2019 by 5-level paging, and then persisted for another 5 years before being noticed and corrected.
2024-09-18Get rid of niche selection's dependence on fields's orderAdwin White-9/+4
2024-09-17get rid of an old hackLukas Markeffsky-1/+5
For structs that cannot be unsized, the layout algorithm sometimes moves unsized fields to the end of the struct, which circumvented the error for unexpected unsized fields and returned an unsized layout anyway. This commit makes it so that the unexpected unsized error is always returned for structs that cannot be unsized, allowing us to remove an old hack and fixing some old ICE.
2024-09-17assert that unexpectedly unsized fields are sized in the param envLukas Markeffsky-27/+34
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-919/+948
2024-09-14compiler: Document AbiAndPrefAlignJubilee Young-0/+8
2024-08-31inhibit layout randomization for BoxThe 8472-8/+18
2024-08-27ABI compat check: detect unadjusted ABI mismatchesRalf Jung-1/+3
2024-08-16Add `warn(unreachable_pub)` to several crates.Nicholas Nethercote-0/+1
It requires no additonal changes to these crates, but will prevent unnecessary `pub`s in the future.
2024-08-01interpret: simplify pointer arithmetic logicRalf Jung-3/+3
2024-07-29Reformat `use` declarations.Nicholas Nethercote-9/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-17Rollup merge of #127769 - compiler-errors:ed-2024-dep, r=oli-obkMatthias Krüger-4/+4
Don't use implicit features in `Cargo.toml` in `compiler/` Fixes compiler crates to stop using implicit features (https://github.com/rust-lang/cargo/issues/12826) which are denied in in edition 2024.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-2/+2
2024-07-15Use dep: for crate dependenciesMichael Goulet-4/+4
2024-07-04Rollup merge of #123043 - GoldsteinE:fix/repr-c-dead-branches, r=oli-obkMatthias Krüger-3/+3
Disable dead variant removal for `#[repr(C)]` enums. This prevents removing dead branches from a `#[repr(C)]` enum (they now get discriminants allocated as if they were inhabited). Implementation notes: ABI of something like ```rust #[repr(C)] enum Foo { Foo(!), } ``` is still `Uninhabited`, but its layout is now computed as if all the branches were inhabited. This seemed to me like a proper way to do it, especially given that ABI sanity check explicitly asserts that type-level uninhabitedness implies ABI uninhabitedness. This probably needs some sort of FCP (given that it changes `#[repr(C)]` layout, which is a stable guarantee), but I’m not sure how to call for one or which team is the most relevant. See https://github.com/rust-lang/unsafe-code-guidelines/issues/500.
2024-06-28Disable dead variant removal for `#[repr(C)]` enums.Goldstein-3/+3
See https://github.com/rust-lang/unsafe-code-guidelines/issues/500.
2024-06-25Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoeristerbors-3/+5
Un-unsafe the `StableOrd` trait Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc. [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Policy.20of.20.60unsafe.60.20within.20the.20compiler). cc [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), #105175, `@michaelwoerister` r? `@Nilstrieb`
2024-06-22Ensure careful consideration is given by implsAlan Egerton-2/+4
Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED` to the `StableOrd` trait to ensure that implementors carefully consider whether the trait's contract is upheld, as incorrect implementations can cause miscompilations.
2024-06-12Un-unsafe the `StableOrd` traitAlan Egerton-2/+2
Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc.
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-1/+3
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-05-21don't inhibit random field reordering on repr(packed(1))Ralf Jung-15/+10