Commit Graph

606 Commits

Author SHA1 Message Date
Albert Larsan
40ba0e84d5
Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
bors
89e0576bd3 Auto merge of #106340 - saethlin:propagate-operands, r=oli-obk
Always permit ConstProp to exploit arithmetic identities

Fixes https://github.com/rust-lang/rust/issues/72751

Initially, I thought I would need to enable operand propagation then do something else, but actually https://github.com/rust-lang/rust/pull/74491 already has the fix for the issue in question! It looks like this optimization was put under MIR opt level 3 due to possible soundness/stability implications, then demoted further to MIR opt level 4 when MIR opt level 2 became associated with `--release`.

Perhaps in the past we were doing CTFE on optimized MIR? We aren't anymore, so this optimization has no stability implications.

r? `@oli-obk`
2023-01-09 11:59:51 +00:00
bors
b1691f6413 Auto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwco
Perform SimplifyLocals before ConstProp.

MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work.

r? `@ghost`
2023-01-07 16:13:18 +00:00
Tomasz Miąsko
3eabea9e2c Remove duplicated elaborate box derefs pass
The pass runs earlier as a part of `run_runtime_lowering_passes`.
2023-01-03 00:00:00 +00:00
Jakob Degen
ee6503a706 Reenable limited top-down MIR inlining 2023-01-01 22:01:29 -08:00
Ben Kimock
82f0973dd5 Always take advantage of arithmetic identities 2023-01-01 23:12:29 -05:00
Camille GILLOT
edc73f9719 Give the correct track-caller location with MIR inlining. 2022-12-25 18:48:13 +00:00
Camille GILLOT
e300abb593 Remove Nop in simplify_locals.
It's cheap and does not change anything.
2022-12-25 18:01:07 +00:00
Camille GILLOT
028b4745f4 Move SimplifyLocals before ConstProp. 2022-12-25 18:01:07 +00:00
Matthias Krüger
d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Jakob Degen
c359ab0b5d Retag argument to drop_in_place unconditionally 2022-12-21 14:59:55 -08:00
Jakob Degen
102040ce76 Retag as FnEntry on drop_in_place 2022-12-21 14:59:55 -08:00
Jeremy Stucki
42d100aad0
Add missing anonymous lifetime 2022-12-20 22:28:22 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
Matthias Krüger
c3af456d6d
Rollup merge of #105930 - JakobDegen:nal-unsound, r=oli-obk
Disable `NormalizeArrayLen`

cc #105929

r? mir-opt
2022-12-20 14:37:32 +01:00
Matthias Krüger
52fe5a1cc1
Rollup merge of #105835 - tmiasko:cleanup-post-borrowck, r=JakobDegen
Refactor post borrowck cleanup passes
2022-12-20 14:37:31 +01:00
bors
eb9e5e711d Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
Improve syntax of `newtype_index`

This makes it more like proper Rust and also makes the implementation a lot simpler.

Mostly just turns weird flags in the body into proper attributes.

It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-20 07:27:01 +00:00
Jakob Degen
4251289f27 Disable NormalizeArrayLen 2022-12-19 17:38:18 -08:00
Dylan DPC
a9005b6cc0
Rollup merge of #105864 - matthiaskrgr:compl, r=Nilstrieb
clippy::complexity fixes

filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool

r? `@compiler-errors`
2022-12-19 14:41:35 +05:30
Matthias Krüger
1da4a49912 clippy::complexity fixes
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
2022-12-19 00:04:28 +01:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Nilstrieb
d679764fb6 Make #[debug_format] an attribute in newtype_index
This removes the `custom` format functionality as its only user was
trivially migrated to using a normal format.

If a new use case for a custom formatting impl pops up, you can add it
back.
2022-12-18 21:37:38 +01:00
Matthias Krüger
8892698903
Rollup merge of #105870 - matthiaskrgr:useless_conv, r=oli-obk
avoid .into() conversion to identical types
2022-12-18 18:57:05 +01:00
Matthias Krüger
0aa4cde747 avoid .into() conversion to identical types 2022-12-18 16:20:32 +01:00
Tomasz Miąsko
62f9084dfa Remove false edges in CleanupPostBorrowck 2022-12-17 19:34:45 +01:00
Tomasz Miąsko
4c3efc7f1b Rename CleanupNonCodegenStatements to CleanupPostBorrowck 2022-12-17 19:34:45 +01:00
Tomasz Miąsko
2a8513d221 Replace visitor with a loop over blocks and statements 2022-12-17 18:23:37 +01:00
Tomasz Miąsko
adf53d4b06 Remove dead code after destination propagation 2022-12-16 00:00:00 +00:00
bors
ec56537c43 Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obk
Custom MIR: Many more improvements

Commits are each atomic changes, best reviewed one at a time, with the exception that the last commit includes all the documentation.

### First commit

Unsafetyck was not correctly disabled before for `dialect = "built"` custom MIR. This is fixed and a regression test is added.

### Second commit

Implements `Discriminant`, `SetDiscriminant`, and `SwitchInt`.

### Third commit

Implements indexing, field, and variant projections.

### Fourth commit

Documents the previous commits and everything else.

There is some amount of weirdness here due to having to beat Rust syntax into cooperating with MIR concepts, but it hopefully should not be too much. All of it is documented.

r? `@oli-obk`
2022-12-15 19:59:48 +00:00
bors
4954a7ef5c Auto merge of #104616 - RalfJung:ctfe-alignment, r=oli-obk,RalfJung
always check alignment during CTFE

We originally disabled alignment checks because they got in the way -- there are some things we do with the interpreter during CTFE which does not correspond to actually running user-written code, but is purely administrative, and we didn't want alignment checks there, so we just disabled them entirely. But with `-Zextra-const-ub-checks` we anyway had to figure out how to disable those alignment checks while doing checks in regular code. So now it is easy to enable CTFE alignment checking by default. Let's see what the perf consequences of that are.

r? `@oli-obk`
2022-12-15 17:04:25 +00:00
Oli Scherer
d9d92ed7da Move alignment failure error reporting to machine 2022-12-15 16:07:35 +00:00
Oli Scherer
d66824dbc4 Make alignment checks a future incompat lint 2022-12-15 16:07:28 +00:00
Matthias Krüger
6cdc83b64e
Rollup merge of #105683 - JakobDegen:dest-prop-storage, r=tmiasko
Various cleanups to dest prop

This makes fixing the issues identified in #105577 easier. A couple changes

 - Use an enum with names instead of a bool
 - Only call `remove_candidates_if` from one place instead of two. Doing it from two places is far too fragile, since any divergence in the behavior between those callsites is likely to be unsound.
 - Remove `is_constant`. Right now we only merge locals, so this doesn't do anything, and the logic would be wrong if it did.

r? `@tmiasko`
2022-12-15 12:46:02 +01:00
Jakob Degen
a5beb7abb9 Various cleanups to dest prop 2022-12-14 23:11:52 -08:00
Oli Scherer
a5cd3bde95 Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
Oli Scherer
1bf80249ae Remove many more cases of mk_substs_trait that can now use the iterator scheme` 2022-12-14 15:36:39 +00:00
Oli Scherer
0fe86aa977 Let mk_fn_def take an iterator instead to simplify some call sites 2022-12-14 15:36:39 +00:00
Jakob Degen
c1b27eea45 Fix unsafetyck disabling for custom MIR 2022-12-14 01:02:35 -08:00
bors
918d0ac38e Auto merge of #104986 - compiler-errors:opaques, r=oli-obk
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias`

Implements https://github.com/rust-lang/types-team/issues/79.

This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so:

```
enum AliasKind {
  Projection,
  Opaque,
}

struct AliasTy<'tcx> {
  def_id: DefId,
  substs: SubstsRef<'tcx>,
}
```

Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example:

```diff
  match ty.kind() {
-   ty::Opaque(..) =>
+   ty::Alias(ty::Opaque, ..) => {}
    _ => {}
  }
```

This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically.

r? `@ghost`
2022-12-14 01:19:24 +00:00
Matthias Krüger
e0e9f3a7b7
Rollup merge of #105659 - JakobDegen:storage-live-borrow, r=davidtwco
Don't require owned data in `MaybeStorageLive`

Small improvement that avoids a clone. I don't expect this to have any noticeable perf effects, but better to have it than not to.

r? ``@tmiasko``
2022-12-13 19:57:12 +01:00
Michael Goulet
61adaf8187 Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
Michael Goulet
c13bd83528 squash OpaqueTy and ProjectionTy into AliasTy 2022-12-13 17:40:27 +00:00
Michael Goulet
7f3af72606 Use ty::OpaqueTy everywhere 2022-12-13 17:29:26 +00:00
Jakob Degen
3522d48112 Don't require owned data in MaybeStorageLive 2022-12-13 04:22:47 -08:00
Gary Guo
9342d1e73e Allow unsafe through inline const
This is handled similar to closures
2022-12-13 01:38:38 +00:00
Matthias Krüger
2daa3bcbc2
Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-dead
compiler: remove unnecessary imports and qualified paths

Some of these imports were necessary before Edition 2021, others were already in the prelude.

I hope it's fine that this PR is so spread-out across files :/
2022-12-11 09:51:57 +01:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Jakob Degen
9fb8da8f8f Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
Matthias Krüger
f1f7560598
Rollup merge of #105317 - RalfJung:retag-rework, r=oli-obk
make retagging work even with 'unstable' places

This is based on top of https://github.com/rust-lang/rust/pull/105301. Only the last two commits are new.

While investigating https://github.com/rust-lang/unsafe-code-guidelines/issues/381 I realized that we would have caught this issue much earlier if the add_retag pass wouldn't bail out on assignments of the form `*ptr = ...`.

So this PR changes our retag strategy:
- When a new reference is created via `Rvalue::Ref` (or a raw ptr via `Rvalue::AddressOf`), we do the retagging as part of just executing that address-taking operation.
- For everything else, we still insert retags -- these retags basically serve to ensure that references stored in local variables (and their fields) are always freshly tagged, so skipping this for assignments like `*ptr = ...` is less egregious.
r? ```@oli-obk```
2022-12-08 12:57:30 +01:00
bors
e60fbaf4ce Auto merge of #105229 - saethlin:zst-writes-to-unions, r=oli-obk
Re-enable removal of ZST writes to unions

This was previously disabled because Miri was lazily allocating unsized locals. But we aren't doing that anymore since  https://github.com/rust-lang/rust/pull/98831, so we can have this optimization back.
2022-12-06 15:35:55 +00:00