Commit Graph

53 Commits

Author SHA1 Message Date
Matthias Krüger
5915309645
Rollup merge of #107971 - saethlin:mir-opt-ub, r=cjgillot
Clearly document intentional UB in mir-opt tests

All of the changed mir-opt test input files did not pass Miri. Now they do.

r? `@cjgillot` because there's a CopyProp test in here that I do not fully understand
2023-02-13 23:25:13 +01:00
Ben Kimock
614df3fd5e Clearly document intentional UB in mir-opt tests
Co-authored-by: Jakob Degen <jakob.e.degen@gmail.com>
2023-02-13 13:50:50 -05:00
bors
585f3eef26 Auto merge of #107851 - cjgillot:sroa-const, r=oli-obk
Put deaggregated statements after original constant.

Fixes https://github.com/rust-lang/rust/issues/107818
2023-02-11 20:59:18 +00:00
bors
5a8dfd933a Auto merge of #85158 - JulianKnodt:array_const_val, r=cjgillot
Mir-Opt for copying enums with large discrepancies

I have been meaning to make this for quite a while, based off of this [hackmd](https://hackmd.io/`@ft4bxUsFT5CEUBmRKYHr7w/rJM8BBPzD).`

I'm not sure where to put this opt now that I've made it, so I'd appreciate suggestions on that!
It's also one long chain of statements, not sure if there's a more friendly format to make it.

r? `@tmiasko`
I would `r` oli but he's on leave so he suggested I `r` tmiasko or wesleywiser.
2023-02-10 21:49:31 +00:00
Camille GILLOT
221ea3080d Put deaggregated statements after original constant. 2023-02-09 17:27:31 +00:00
kadmin
15d4728cda Add de-init to destination place 2023-02-08 02:04:07 +00:00
Matthias Krüger
306dbaf574
Rollup merge of #107662 - cjgillot:copy-projection, r=oli-obk
Turn projections into copies in CopyProp.

The current implementation can leave behind projections that are moved out several times.

This PR widens the check to turn such moves into copies: a move out of a projection of a copy is equivalent to a copy of the original projection.
2023-02-07 17:57:15 +01:00
kadmin
15f4eec7a9 Leave FIXME for wasm layout difference.
There is a distinction between running this on wasm and i686, even though they should be
identical. This technically is not _incorrect_, it's just an unexpected difference, which is
worth investigating, but not for correctness.
2023-02-07 09:37:55 +00:00
kadmin
610e1a1e05 Add tag for ignoring wasm 2023-02-07 09:37:55 +00:00
kadmin
5d9f5145ac Rm allocation in candidate
Instead of storing an extra array for discriminant values, create an allocation there and store
those in an allocation immediately.
2023-02-07 09:37:55 +00:00
Camille GILLOT
51ef82d19b Bless 32bit tests. 2023-02-05 13:51:37 +00:00
Camille GILLOT
8e05ab04e5 Run SROA to fixpoint. 2023-02-05 12:08:42 +00:00
Camille GILLOT
42c9514629 Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
Camille GILLOT
dc4fe8e295 Make SROA expand assignments. 2023-02-05 11:42:11 +00:00
Camille GILLOT
0843acbea6 Fix SROA without deaggregation. 2023-02-05 08:37:03 +00:00
Camille GILLOT
5c1cb5bbc6 Turn projections into copies in CopyProp. 2023-02-04 23:33:33 +00:00
Camille GILLOT
5c39ba2027 Bless 32bit. 2023-02-02 23:26:34 +00:00
Camille GILLOT
83173c68f5 Add partial propagation test. 2023-02-02 23:26:29 +00:00
Camille GILLOT
10ec94930b Bless tests. 2023-02-02 23:26:26 +00:00
Camille GILLOT
6a0b218161 Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
Camille GILLOT
feccf469fb Interpret aggregates. 2023-02-02 23:09:51 +00:00
Matthias Krüger
6917040cf0
Rollup merge of #107524 - cjgillot:both-storage, r=RalfJung
Remove both StorageLive and StorageDead in CopyProp.

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

https://github.com/rust-lang/rust/pull/106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB.

So when removing storage statements, we have to remove both StorageLive and StorageDead.

~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~
2023-02-02 17:14:06 +01:00
Camille GILLOT
e8ac0404bd Remove assignment. 2023-01-31 18:07:57 +00:00
Camille GILLOT
3c10cf088a Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
Camille GILLOT
05ee406cc8 Add test. 2023-01-31 17:49:57 +00:00
Camille GILLOT
a9aed861ac Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
bors
2a4b00beaa Auto merge of #106908 - cjgillot:copyprop-ssa, r=oli-obk
Implement simple CopyPropagation based on SSA analysis

This PR extracts the "copy propagation" logic from https://github.com/rust-lang/rust/pull/106285.

MIR may produce chains of assignment between locals, like `_x = move? _y`.
This PR attempts to remove such chains by unifying locals.

The current implementation is a bit overzealous in turning moves into copies, and in removing storage statements.
2023-01-29 13:01:06 +00:00
Camille GILLOT
d3d626920a Bless mir-opt tests. 2023-01-27 22:01:47 +00:00
Camille GILLOT
e2387ad484 Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
Camille GILLOT
d29dc057ba Do not merge locals that have their address taken. 2023-01-27 18:22:45 +00:00
Camille GILLOT
8f1dbe54ea Discard raw pointers from SSA locals. 2023-01-27 18:22:45 +00:00
Camille GILLOT
d45815eb4a Only consider a local to be SSA if assignment dominates all uses. 2023-01-27 18:22:45 +00:00
Camille GILLOT
38b55dc684 Add tests. 2023-01-27 18:22:45 +00:00
Camille GILLOT
6ed9f8f62e Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
Camille GILLOT
8f7e441a54 Add mir-opt test. 2023-01-27 18:22:44 +00:00
Camille GILLOT
8ba0cd6c9e Make tests unit. 2023-01-27 18:22:44 +00:00
Jakob Degen
d7f59e91e0 Custom mir: Add support for some remaining, easy to support constructs 2023-01-26 03:29:28 -08:00
bors
e187f8871e Auto merge of #107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #106407 (Improve proc macro attribute diagnostics)
 - #106960 (Teach parser to understand fake anonymous enum syntax)
 - #107085 (Custom MIR: Support binary and unary operations)
 - #107086 (Print PID holding bootstrap build lock on Linux)
 - #107175 (Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`)
 - #107204 (suggest qualifying bare associated constants)
 - #107248 (abi: add AddressSpace field to Primitive::Pointer )
 - #107272 (Implement ObjectSafe and WF in the new solver)
 - #107285 (Implement `Generator` and `Future` in the new solver)
 - #107286 (ICE in new solver if we see an inference variable)
 - #107313 (Add Style Team Triagebot config)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-26 06:23:14 +00:00
Matthias Krüger
f3644ca64d
Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obk
Custom MIR: Support binary and unary operations

Lower binary and unary operations directly to corresponding unchecked MIR
operations. Ultimately this might not be syntax we want, but it allows for
experimentation in the meantime.

r? ````@oli-obk```` ````@JakobDegen````
2023-01-26 06:15:24 +01:00
bors
885bf62887 Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillot
InstCombine away intrinsic validity assertions

This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
2023-01-26 03:10:52 +00:00
Jakob Degen
ad7393668f Delete SimplifyArmIdentity and SimplifyBranchSame mir opts 2023-01-24 04:13:52 -08:00
Matthias Krüger
66a9006759
Rollup merge of #107067 - tmiasko:custom-mir-storage-statements, r=oli-obk
Custom MIR: Support storage statements

r? `@oli-obk` `@JakobDegen`
2023-01-20 07:16:11 +01:00
Tomasz Miąsko
d3cfe97a8a Custom MIR: Support binary and unary operations 2023-01-19 22:00:33 +01:00
Tomasz Miąsko
ca3d55e32d Custom MIR: Support storage statements 2023-01-19 11:53:33 +01:00
Arpad Borsos
96931a787a
Transform async ResumeTy in generator transform
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-19 09:03:05 +01:00
Boxy
1171fe5c45 i am free 2023-01-18 04:45:43 +00:00
bors
af669c2684 Auto merge of #106850 - cjgillot:issue-106141, r=oli-obk
Make the inlining destination a Local.

Fixes https://github.com/rust-lang/rust/issues/106141
2023-01-16 12:30:49 +00:00
Ben Kimock
662199f125 InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
Camille GILLOT
de9a5b076a Make the inlining destination a Local. 2023-01-14 12:09:06 +00:00
Camille GILLOT
1c327e1133 Add test. 2023-01-14 11:41:22 +00:00