about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-23733/+0
2023-01-09Auto merge of #106340 - saethlin:propagate-operands, r=oli-obkbors-0/+46
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-07Auto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwcobors-492/+354
Perform SimplifyLocals before ConstProp. MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work. r? `@ghost`
2023-01-01Reenable limited top-down MIR inliningJakob Degen-91/+184
2023-01-01Always take advantage of arithmetic identitiesBen Kimock-0/+46
2022-12-25Give the correct track-caller location with MIR inlining.Camille GILLOT-16/+16
2022-12-25Remove Nop in simplify_locals.Camille GILLOT-54/+0
It's cheap and does not change anything.
2022-12-25Move SimplifyLocals before ConstProp.Camille GILLOT-421/+332
2022-12-25Make tests unit.Camille GILLOT-17/+22
2022-12-22Auto merge of #103957 - JakobDegen:drop-retag, r=RalfJungbors-2/+5
Retag as FnEntry on `drop_in_place` This commit changes the mir drop shim to always retag its argument as if it were a `&mut`. cc rust-lang/unsafe-code-guidelines#373
2022-12-21Retag as FnEntry on `drop_in_place`Jakob Degen-2/+5
2022-12-21Clarify that raw retags are not permitted in MirJakob Degen-10/+6
2022-12-20Rollup merge of #105930 - JakobDegen:nal-unsound, r=oli-obkMatthias Krüger-18/+10
Disable `NormalizeArrayLen` cc #105929 r? mir-opt
2022-12-20Rollup merge of #105835 - tmiasko:cleanup-post-borrowck, r=JakobDegenMatthias Krüger-9/+7
Refactor post borrowck cleanup passes
2022-12-19Disable `NormalizeArrayLen`Jakob Degen-18/+10
2022-12-18Rollup merge of #105420 - tmiasko:dest-prop-dead-code, r=JakobDegenMatthias Krüger-0/+104
Remove dead code after destination propagation Fixes #105428. cc `@JakobDegen`
2022-12-17./x.py test --blessTomasz Miąsko-8/+6
2022-12-17Rename CleanupNonCodegenStatements to CleanupPostBorrowckTomasz Miąsko-1/+1
2022-12-16Support call and drop terminators in custom mirJakob Degen-0/+180
2022-12-16Remove dead code after destination propagationTomasz Miąsko-0/+104
2022-12-14Support more projections in custom mirJakob Degen-0/+151
2022-12-14Support common enum operations in custom mirJakob Degen-0/+201
2022-12-14Fix unsafetyck disabling for custom MIRJakob Degen-0/+24
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-247/+247
2022-12-08Rollup merge of #105317 - RalfJung:retag-rework, r=oli-obkMatthias Krüger-29/+0
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-06Auto merge of #105229 - saethlin:zst-writes-to-unions, r=oli-obkbors-34/+43
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-06make retagging work even with 'unstable' placesRalf Jung-29/+0
2022-12-06Auto merge of #105119 - JakobDegen:inline-experiments, r=cjgillotbors-93/+237
Disable top down MIR inlining The current MIR inliner has exponential behavior in some cases: <https://godbolt.org/z/7jnWah4fE>. The cause of this is top-down inlining, where we repeatedly do inlining like `call_a() => { call_b(); call_b(); }`. Each decision on its own seems to make sense, but the result is exponential. Disabling top-down inlining fundamentally prevents this. Each call site in the original, unoptimized source code is now considered for inlining exactly one time, which means that the total growth in MIR size is limited to number of call sites * inlining threshold. Top down inlining may be worth re-introducing at some point, but it needs to be accompanied with a principled way to prevent this kind of behavior.
2022-12-03Re-enable removal of ZST writes to unionsBen Kimock-34/+43
2022-12-01Disable top-down inliningJakob Degen-93/+237
2022-11-29Improve spans in custom mirJakob Degen-34/+34
2022-11-29Support statics in custom mirJakob Degen-0/+40
2022-11-29Support most constant kinds in custom mirJakob Degen-0/+45
2022-11-29Support arbitrary `let` statements in custom mirJakob Degen-0/+50
2022-11-26Rewrite dest prop.Jakob Degen-357/+416
This fixes a number of correctness issues from the previous version. Additionally, we use a new strategy which has much better performance charactersitics and also finds more opportunities to apply the optimization.
2022-11-26Rollup merge of #104121 - ↵Matthias Krüger-21/+56
Lokathor:mir-opt-when-instruction-set-missing-on-callee, r=tmiasko Refine `instruction_set` MIR inline rules Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller. cc ``@oli-obk`` [Edit] Zulip Context: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/What.20exactly.20does.20the.20MIR.20optimizer.20do.3F
2022-11-25Refine instruction_set inline rulesLokathor-21/+56
Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller.
2022-11-18rename to `string_deref_patterns`Deadbeef-1/+1
2022-11-18Adding more testsDeadbeef-0/+86
2022-11-15Mark test as panic=abort.Camille GILLOT-24/+10
2022-11-15Flatten aggregates into locals.Camille GILLOT-41/+693
2022-11-15Auto merge of #101168 - jachris:dataflow-const-prop, r=oli-obkbors-13/+920
Add new MIR constant propagation based on dataflow analysis The current constant propagation in `rustc_mir_transform/src/const_prop.rs` fails to handle many cases that would be expected from a constant propagation optimization. For example: ```rust let x = if true { 0 } else { 0 }; ``` This pull request adds a new constant propagation MIR optimization pass based on the existing dataflow analysis framework. Since most of the analysis is not unique to constant propagation, a generic framework has been extracted. It works on top of the existing framework and could be reused for other optimzations. Closes #80038. Closes #81605. ## Todo ### Essential - [x] [Writes to inactive enum variants](https://github.com/rust-lang/rust/pull/101168#pullrequestreview-1089493974). Resolved by rejecting the registration of places with downcast projections for now. Could be improved by flooding other variants if mutable access to a variant is observed. - [X] Handle [`StatementKind::CopyNonOverlapping`](https://github.com/rust-lang/rust/pull/101168#discussion_r957774914). Resolved by flooding the destination. - [x] Handle `UnsafeCell` / `!Freeze` correctly. - [X] Overflow propagation of `CheckedBinaryOp`: Decided to not propagate if overflow flag is `true` (`false` will still be propagated) - [x] More documentation in general. - [x] Arguments for correctness, documentation of necessary assumptions. - [x] Better performance, or alternatively, require `-Zmir-opt-level=3` for now. ### Extra - [x] Add explicit unreachability, i.e. upgrading the lattice from $\mathbb{P} \to \mathbb{V}$ to $\set{\bot} \cup (\mathbb{P} \to \mathbb{V})$. - [x] Use storage statements to improve precision. - [ ] Consider opening issue for duplicate diagnostics: https://github.com/rust-lang/rust/pull/101168#issuecomment-1276609950 - [ ] Flood moved-from places with $\bot$ (requires some changes for places with tracked projections). - [ ] Add downcast projections back in. - [ ] [Algebraic simplifications](https://github.com/rust-lang/rust/pull/101168#discussion_r957967878) (possibly with a shared API; done by old const prop). - [ ] Propagation through slices / arrays. - [ ] Find other optimizations that are done by old `const_prop.rs`, but not by this one.
2022-11-14Bless graphviz testsJannis Christopher Köhl-5/+5
2022-11-12Exclude locals completely, instead of individual placesJannis Christopher Köhl-0/+67
2022-11-11Add test for repr(transparent) with scalarJannis Christopher Köhl-0/+56
2022-11-09Fix struct field tracking and add tests for itJannis Christopher Köhl-0/+137
2022-11-09Completely remove tracking of references for nowJannis Christopher Köhl-576/+169
2022-11-08Add support for custom MIR parsingJakob Degen-0/+136
2022-11-07Fix rebaseJannis Christopher Köhl-2/+1
2022-11-07Remove copy of current const prop tests and add a few new testsJannis Christopher Köhl-2500/+253