-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Sync rustc_codegen_cranelift #95142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync rustc_codegen_cranelift #95142
Conversation
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
This fixes a miscompilation
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
This reduces the amount of unstable features used by cg_clif
Only rustc_private is still enabled as cg_clif by definition needs to use internal rustc api's.
This reduces binary sizes by a decent amount: libstd.so: 17% reduction mini_core_hello_world: 27% reduction simple-raytracer: 27% reduction This also improves compile time of simple-raytracer by 0.5s (4% +- 2%) In addition it is also a pre-requisite for building standalone binaries.
Replace a lot of print+trap with plain trap
This saves 40-50s on CI as the repo history can be skipped
Run more rustc tests
128bit atomics are unstable and only enabled on AArch64 and x86_64 macOS. Cranelift doesn't support 128bit atomics yet.
@bors r+ subtree sync |
📌 Commit ce7f5ec has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (4767cce): comparison url. Summary: This benchmark run did not return any relevant results. 1 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
r? @ghost
@rustbot label +A-codegen +A-cranelift +T-compiler