Skip to content

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

Merged
merged 52 commits into from
Mar 20, 2022
Merged

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Mar 20, 2022

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler

bjorn3 and others added 30 commits February 23, 2022 11:49
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
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend labels Mar 20, 2022
@bjorn3
Copy link
Member Author

bjorn3 commented Mar 20, 2022

@bors r+ subtree sync

@bors
Copy link
Collaborator

bors commented Mar 20, 2022

📌 Commit ce7f5ec has been approved by bjorn3

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 20, 2022
@bors
Copy link
Collaborator

bors commented Mar 20, 2022

⌛ Testing commit ce7f5ec with merge 4767cce...

@bors
Copy link
Collaborator

bors commented Mar 20, 2022

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing 4767cce to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 20, 2022
@bors bors merged commit 4767cce into rust-lang:master Mar 20, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 20, 2022
@bjorn3 bjorn3 deleted the sync_cg_clif-2022-03-20 branch March 20, 2022 20:04
@rust-timer
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants