Skip to content
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 #94285

Merged
merged 83 commits into from
Feb 23, 2022
Merged

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Feb 23, 2022

r? @ghost

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

nbdd0121 and others added 30 commits October 20, 2021 19:42
Remove `NullOp::Box`

Follow up of rust-lang#89030 and MCP rust-lang/compiler-team#460.

~1 month later nothing seems to be broken, apart from a small regression that rust-lang#89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely.

r? `@jonas-schievink`
`@rustbot` label T-compiler
This version fixes the regressions in 0.79.0
Using the arguments often saves a layout_of call
This should reduce compile times of cg_clif
Also directly use an array instead of going through a tuple. This
reduces the amount of llvm ir lines for this function by almost half
from 3086 to 1662.
This reduces the amount of llvm ir lines for this function by a little
over half from 1662 to 781.
This effectively outlines it, significantly reducing the size of
the codegen_simd_intrinsic_call llvm ir from 10419 lines to 6378 lines.
Real simd support will need an overhaul in the future anyway. For now it
only complicates the code.
…edness doesn't matter

This is slightly more verbose when invoking the macro.
This halves the total amount of llvm ir lines for simd related functions
from 18227 to 9604.
This reduces the total amount of llvm ir lines for simd related
functions from 9604 to 9467.
…times

Refactor the intrinsics module for slightly better build times
y.rs can't be rustfmt'ed without making it no longer be a valid bash
script.
The field is also renamed from `ident` to `name. In most cases,
we don't actually need the `Span`. A new `ident` method is added
to `VariantDef` and `FieldDef`, which constructs the full `Ident`
using `tcx.def_ident_span()`. This method is used in the cases
where we actually need an `Ident`.

This makes incremental compilation properly track changes
to the `Span`, without all of the invalidations caused by storing
a `Span` directly via an `Ident`.
bjorn3 and others added 18 commits February 13, 2022 12:24
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.
Specifically, change `Region` from this:
```
pub type Region<'tcx> = &'tcx RegionKind;
```
to this:
```
pub struct Region<'tcx>(&'tcx Interned<RegionKind>);
```

This now matches `Ty` and `Predicate` more closely.

Things to note
- Regions have always been interned, but we haven't been using pointer-based
  `Eq` and `Hash`. This is now happening.
- I chose to impl `Deref` for `Region` because it makes pattern matching a lot
  nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`.
- Various methods are moved from `RegionKind` to `Region`.
- There is a lot of tedious sigil changes.
- A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a
  `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`.
- A couple of test outputs change slightly, I'm not sure why, but the new
  outputs are a little better.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.
The previous approach of checking for the reserve-r9 target feature
didn't actually work because LLVM only sets this feature very late when
initializing the per-function subtarget.
Checking of asm! register operands now properly takes function
attributes such as #[target_feature] and #[instruction_set] into
account.
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes rust-lang#92378
Fixes rust-lang#85247

r? ``@nagisa``
@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 Feb 23, 2022
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 23, 2022

@bors r+ subtree sync

@bors
Copy link
Contributor

bors commented Feb 23, 2022

📌 Commit f596dce 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 Feb 23, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2022
…askrgr

Rollup of 12 pull requests

Successful merges:

 - rust-lang#94128 (rustdoc: several minor fixes)
 - rust-lang#94137 (rustdoc-json: Better Header Type)
 - rust-lang#94213 (fix names in feature(...) suggestion)
 - rust-lang#94240 (Suggest calling .display() on `PathBuf` too)
 - rust-lang#94253 (Use 2021 edition in ./x.py fmt)
 - rust-lang#94259 (Bump download-ci-llvm-stamp for llvm-nm inclusion)
 - rust-lang#94260 (Fix rustdoc infinite redirection generation)
 - rust-lang#94263 (Typo fix: Close inline-code backtick)
 - rust-lang#94264 (Fix typo.)
 - rust-lang#94271 (Miri: extend comments on downcast operation)
 - rust-lang#94280 (Rename `region_should_not_be_omitted` to `should_print_region`)
 - rust-lang#94285 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8f53bdb into rust-lang:master Feb 23, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 23, 2022
@bjorn3 bjorn3 deleted the sync_cg_clif-2022-02-23 branch February 24, 2022 12:33
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 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.