summary refs log tree commit diff
path: root/compiler/rustc_abi/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2024-05-21don't inhibit random field reordering on repr(packed(1))Ralf Jung-11/+4
2024-05-18Temporarily revert to NonZeroUsize in rustc-abi to fix building on stableLaurențiu Nicola-2/+2
2024-05-11Make `index_by_increasing_offset` return one item for primitivesScott McMurray-1/+6
2024-05-11Unify `Rvalue::Aggregate` paths in cg_ssaScott McMurray-1/+1
2024-05-10Rollup merge of #124797 - beetrees:primitive-float, r=davidtwcoMatthias Krüger-12/+38
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-05-08Use generic `NonZero`.Markus Reiter-2/+2
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-12/+38
2024-05-03Rollup merge of #124555 - Zalathar:init-coverage, r=nnethercoteMatthias Krüger-0/+2
coverage: Clean up creation of MC/DC condition bitmaps This PR improves the code for creating and initializing [MC/DC](https://en.wikipedia.org/wiki/Modified_condition/decision_coverage) condition bitmap variables, as introduced by #123409 and modified by #124255. - The condition bitmap variables are now created eagerly at the start of per-function codegen, via a new `init_coverage` method in `CoverageInfoBuilderMethods`. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement. - As a result, we can now create and initialize those bitmaps using existing safe APIs, instead of having to perform our own unsafe call to `llvm::LLVMBuildAlloca`. - This PR also tweaks the way we count the number of condition bitmaps needed, by tracking the total number of bitmaps needed (max depth + 1), instead of only tracking the maximum depth. This reduces the potential for subtle off-by-one confusion.
2024-05-01Align: add bytes_usize and bits_usizeRalf Jung-0/+10
2024-05-01coverage: Set up MC/DC bitmaps without additional unsafe codeZalathar-0/+2
Because this now always takes place at the start of the function, we can just use the normal `alloca` method and then initialize each bitmap immediately. This patch also moves bitmap setup out of the `mcdc_parameters` method, because there is no longer any particular reason for it to be there.
2024-04-28Rename `inihibit_union_abi_opt()` to `inihibits_union_abi_opt()`Gurinder Singh-1/+1
The present tense makes it read more naturally at use site i.e. "this repr _inhibits_ optimizations"
2024-04-01Use the `Align` type when parsing alignment attributesbeetrees-3/+4
2024-03-05only set noalias on Box with the global allocatorRalf Jung-2/+5
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+12
Make changes necessary to support these types in the compiler.
2024-02-26fix some references to no-longer-existing ReprOptions.layout_seedRalf Jung-1/+1
2024-01-16Fix `rustc_abi` build on stableNadrieril-1/+8
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-7/+7
2023-12-30Update to bitflags 2 in the compilerNilstrieb-6/+9
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-05Make the randomize feature of rustc_abi additivehkalbasi-3/+2
2023-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+2
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-0/+1
happens
2023-10-04Remove unnecessary features from rustc_abiLukas Wirth-4/+5
2023-10-02Add some docs regarding rustc_abi rust-analyzer compat changesLukas Wirth-0/+4
2023-10-02Cfg out ReprOption::field_shuffle_seedLukas Wirth-4/+2
2023-10-02Add VariantIdx backLukas Wirth-30/+11
2023-10-02Move FieldIdx and Layout to rustc_targetLukas Wirth-81/+0
2023-10-02Bring back generic FieldIdxLukas Wirth-18/+22
2023-10-02Unglob rustc_abi importsLukas Wirth-4/+14
2023-10-01Remove unnecessary `pub`s.Nicholas Nethercote-3/+3
2023-10-01Rename two parsing closures.Nicholas Nethercote-11/+12
To match `parse_address_space` and `parse_bits` above.
2023-10-01Minor comment and whitespace tweaks.Nicholas Nethercote-19/+21
2023-09-08turns out Layout has some more things to worry about -- move ABI comparison ↵Ralf Jung-1/+23
into helper function like is_bool, and some special magic extra fields
2023-09-08accept some differences for rustc_abi(assert_eq), so that we can test more ↵Ralf Jung-0/+17
things to be compatible
2023-08-29add is_1zst helper methodRalf Jung-0/+10
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-12/+7
2023-07-25Rollup merge of #114060 - davidtwco:issue-113279, r=wesleywiserMatthias Krüger-1/+0
abi: unsized field in union - assert to delay bug Fixes #113279. > Unions cannot have unsized fields, and as such, layout computation for unions asserts that each union field is sized (as this would normally have halted compilation earlier). > > However, if a generator ends up with an unsized local - a circumstance in which an error will always have been emitted earlier, for example, if attempting to dereference a `&str` - then the generator transform will produce a union with an unsized field. > > Since https://github.com/rust-lang/rust/pull/110107, later passes will be run, such as constant propagation, and can attempt layout computation on the generator, which will result in layout computation of `str` in the context of it being a field of a union - and so the aforementioned assertion would cause an ICE. > > It didn't seem appropriate to try and detect this case in the MIR body and skip this specific pass; tainting the MIR body or delaying a bug from the generator transform (or elsewhere) wouldn't prevent this either (as neither would prevent the later pass from running); and tainting when the deref of `&str` is reported, if that's possible, would unnecessarily prevent potential other errors from being reported later in compilation, and is very tailored to this specific case of getting a unsized type in a generator. > > Given that this circumstance can only happen when an error should have already been reported, the correct fix appears to be just changing the assert to a delayed bug. This will still assert if there is some circumstance where this occurs and no error has been reported, but it won't crash the compiler in this instance. While debugging this, I noticed a translation ICE in a delayed bug, so I fixed that too: > During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and used to emit a delayed bug indicating a diagnostic was buffered - when the buffered diagnostic is translated, then the cloned `MultiSpan` may contain labels which can only render with the diagnostic's arguments, but the delayed bug being emitted won't have those arguments. Adds a function which clones `MultiSpan` without also cloning the contained labels, and use this function when creating the buffered diagnostic delayed bug.
2023-07-25abi: unsized field in union - assert to delay bugDavid Wood-1/+0
Unions cannot have unsized fields, and as such, layout computation for unions asserts that each union field is sized (as this would normally have halted compilation earlier). However, if a generator ends up with an unsized local - a circumstance in which an error will always have been emitted earlier, for example, if attempting to dereference a `&str` - then the generator transform will produce a union with an unsized field. Since #110107, later passes will be run, such as constant propagation, and can attempt layout computation on the generator, which will result in layout computation of `str` in the context of it being a field of a union - and so the aforementioned assertion would cause an ICE. It didn't seem appropriate to try and detect this case in the MIR body and skip this specific pass; tainting the MIR body or delaying a bug from the generator transform (or elsewhere) wouldn't prevent this either (as neither would prevent the later pass from running); and tainting when the deref of `&str` is reported, if that's possible, would unnecessarily prevent potential other errors from being reported later in compilation, and is very tailored to this specific case of getting a unsized type in a generator. Given that this circumstance can only happen when an error should have already been reported, the correct fix appears to be just changing the assert to a delayed bug. This will still assert if there is some circumstance where this occurs and no error has been reported, but it won't crash the compiler in this instance. Signed-off-by: David Wood <david@davidtw.co>
2023-07-25interpret: refactor projection code to work on a common trait, and use that ↵Ralf Jung-1/+1
for visitors
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-98/+10
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Track (partial) niche information in `NaiveLayout`Moulins-2/+8
Still more complexity, but this allows computing exact `NaiveLayout`s for null-optimized enums, and thus allows calls like `transmute::<Option<&T>, &U>()` to work in generic contexts.
2023-07-21CTFE: move `target_{i, u}size_{min, max)` to `rustc_abi::TargetDataLayout`Moulins-11/+13
2023-07-21recover null-ptr optimization by adding a special case to the niching logicMoulins-8/+12
2023-07-21support non-null pointer niches in CTFEMoulins-0/+37
2023-07-21restrict the valid range of references if `-Z reference-niches` is setMoulins-0/+31
Note that this doesn't actually work at all, as many places in rustc assume that references only have the null niche.
2023-07-21add crate-local `-Z reference_niches` unstable flag (does nothing for now)Moulins-0/+8
2023-07-14i686-windows: make requested alignment > 4 special case apply transitivelyErik Desjardins-7/+7