about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2021-12-15Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514Matthias Krüger-2/+2
fix clippy::single_char_pattern perf findings
2021-12-15Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Return an error when `eval_rvalue_with_identities` failsTomasz Miąsko-52/+34
Previously some code paths would fail to evaluate the rvalue, while incorrectly indicating success with `Ok`. As a result the previous value of lhs could have been incorrectly const propagated.
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-2/+2
2021-12-14Correct the unsoundness in the `EarlyOtherwiseBranch` mir optJakob Degen-274/+307
This optimization pass previously made excessive assumptions as to the nature of the blocks being optimized. We remove those assumptions and make sure to rigorously justify all changes that are made to the MIR. Details can be found in the file.
2021-12-13use try_normalize_erasing_regions in RevealAllVisitorb-naber-1/+4
2021-12-09give more help in the unaligned_references lintRalf Jung-0/+5
2021-12-08Use Vec extend instead of repeated pushes in several placesJakub Beránek-3/+1
2021-12-08Rollup merge of #91638 - scottmcm:less-inband-2-of-28, r=petrochenkovMatthias Krüger-119/+117
Remove `in_band_lifetimes` from `rustc_mir_transform` Like #91580, this was inspired by the conversation in #44524 about possibly removing the feature from the compiler. This crate is a heavy `'tcx` user, so is a nice case study. r? ``@petrochenkov`` Three interesting ones: This one had the `'tcx` declared on the function, despite the trait taking a `'tcx`: ```diff -impl Visitor<'_> for UsedLocals { +impl<'tcx> Visitor<'tcx> for UsedLocals { fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { ``` This one use in-band for one, and underscore for the other: ```diff -pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) { +pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { ``` A spurious name, since there's no single-use-lifetime warning: ```diff -pub fn run_passes(tcx: TyCtxt<'tcx>, body: &'mir mut Body<'tcx>, passes: &[&dyn MirPass<'tcx>]) { +pub fn run_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, passes: &[&dyn MirPass<'tcx>]) { ```
2021-12-08Rollup merge of #91577 - ecstatic-morse:mir-pass-manager-cleanup, r=oli-obkMatthias Krüger-16/+15
Address some FIXMEs left over from #91475 This shouldn't change behavior, only clarify what we're currently doing. I filed #91576 to see if the treatment of generator drop shims is intentional. cc #91475
2021-12-07Remove `in_band_lifetimes` from `rustc_mir_transform`Scott McMurray-119/+117
This one is a heavy `'tcx` user. Two interesting ones: This one had the `'tcx` declared on the function, despite the trait taking a `'tcx`: ```diff -impl Visitor<'_> for UsedLocals { +impl<'tcx> Visitor<'tcx> for UsedLocals { fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { ``` This one use in-band for one, and underscore for the other: ```diff -pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) { +pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { ```
2021-12-06Auto merge of #91279 - scottmcm:small-refactor, r=nagisabors-23/+3
Small mir-opt refactor Hopefully-non-controversial changes from some not-ready-yet work that I'd figured I'd submit on their own.
2021-12-05Make treatment of generator drop shims explicitDylan MacKenzie-14/+14
Notably, the passes at the end of `make_shim` aren't applied to them.
2021-12-05Remove unnecessary FIXME (answered by Oli)Dylan MacKenzie-2/+1
2021-12-05Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obkbors-270/+399
Add a MIR pass manager (Taylor's Version) The final draft of #91386 and #77665. While the compile-time constraints in #91386 are cool, I decided on a more minimal approach for now. I want to explore phase constraints and maybe relative-ordering constraints in the future, though. This should preserve existing behavior **exactly** (please let me know if it doesn't) while making the following changes to the way we organize things today: - Each `MirPhase` now corresponds to a single MIR pass. `run_passes` is not responsible for listing the correct MIR phase. - `run_passes` no longer silently skips passes if the declared MIR phase is greater than or equal to the body's. This has bitten me multiple times. If you want this behavior, you can always branch on `body.phase` yourself. - If your pass is solely to emit errors, you can use the `MirLint` interface instead, which gets a shared reference to `Body` instead of a mutable one. By differentiating the two, I hope to make it clearer in the short term where lints belong in the pipeline. In the long term perhaps we could enforce this at compile-time? - MIR is no longer dumped for passes that aren't enabled, or for lints. I tried to check that `-Zvalidate` still works correctly, since the MIR phase is now updated as soon as the associated pass is done, instead of at the end of all the passes in `run_passes`. However, it looks like `-Zvalidate` is broken with current nightlies anyways :cry: (it spits out a bunch of errors). cc `@oli-obk` `@wesleywiser` r? rust-lang/wg-mir-opt
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-2/+16
2021-12-02Don't "simplify" during optimizations if optimizations are disabledDylan MacKenzie-6/+37
2021-12-02Skip shim passes if they've already been runDylan MacKenzie-0/+8
Looks like Generator drop shims already have `post_borrowck_cleanup` run on them. That's a bit surprising, since it means they're getting const- and maybe borrow-checked? This merits further investigation, but for now just preserve the status quo.
2021-12-02Use new MIR pass managerDylan MacKenzie-174/+79
2021-12-02Add pass for simple phase changeDylan MacKenzie-0/+21
2021-12-02Update passes with new interfaceDylan MacKenzie-98/+136
2021-12-02Implement a pass managerDylan MacKenzie-0/+126
2021-12-02Rollup merge of #91410 - ecstatic-morse:const-precise-live-drops-take-2, ↵Matthias Krüger-18/+229
r=oli-obk Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline Should mitigate the issues found during MCP on #73255. Once this is done, we should clean up the queries a bit, since I think `mir_drops_elaborated_and_const_checked` can be merged back into `mir_promoted`. Fixes #90770. cc ``@rust-lang/wg-const-eval`` r? ``@nikomatsakis`` (since they reviewed #71824)
2021-11-30Move post-elaboration const-checking earlier in the pipelineDylan MacKenzie-2/+14
Instead we run `RemoveFalseEdges` and `RemoveUninitDrops` at the appropriate time. The extra `SimplifyCfg` avoids visiting unreachable blocks during `RemoveUninitDrops`.
2021-11-30Add rationale for `RemoveUnneededDrops`Dylan MacKenzie-1/+5
...since its name is very close to `RemoveUninitDrops`.
2021-11-30Add `RemoveUninitDrops` MIR passDylan MacKenzie-0/+172
2021-11-30Separate `RemoveFalseEdges` from `SimplifyBranches`Dylan MacKenzie-15/+38
Otherwise dataflow state will propagate along false edges and cause things to be marked as maybe init unnecessarily. These should be separate, since `SimplifyBranches` also makes `if true {} else {}` into a `goto`, which means we wouldn't lint anything in the `else` block.
2021-11-30Rollup merge of #91294 - cjgillot:process-elem, r=jackh726Matthias Krüger-42/+0
Visit type in process_projection_elem. Instead of reimplementing it for each visitor.
2021-11-29Don't re-export `MirPass`Dylan MacKenzie-2/+1
2021-11-27Visit type in process_projection_elem.Camille GILLOT-42/+0
2021-11-26Small mir-opt refactorScott McMurray-23/+3
Hopefully-non-controversial changes from some not-ready-yet work that I'd figured I'd submit on their own.
2021-11-20Fix a variant index and variant discriminant confusionTomasz Miąsko-1/+4
Previously for enums using the `Variants::Single` layout, the variant index was being confused with its discriminant. For example, in the case of `enum E { A = 1 }`. Use `discriminant_for_variant` to avoid the issue.
2021-11-20Use `IndexVec::indices` instead of reimplementing itTomasz Miąsko-6/+2
The change is limited to the iteration over indices instead of using `basic_blocks_mut()` directly, in the case the previous implementation intentionally avoided invalidating the caches stored in MIR body.
2021-11-20Remove redundant check for promotedsTomasz Miąsko-4/+0
For some time CTFE has been using a dedicated MIR which is never optimized, so the check for promoted became redundant.
2021-11-08impl Copy/Clone for arrays in std, not in compilerbstrie-149/+0
2021-11-06Rollup merge of #90649 - cjgillot:reveal-all-2, r=lcnrMatthias Krüger-1/+1
Run reveal_all on MIR when inlining is activated. Fix logic error in https://github.com/rust-lang/rust/pull/85254 which prevented the pass from running when needed. Fixes https://github.com/rust-lang/rust/issues/78442 r? ``@lcnr``
2021-11-06use matches!() macro in more placesMatthias Krüger-8/+6
2021-11-06Run reveal_all on MIR more often.Camille GILLOT-1/+1
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-25Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrumbors-1/+0
Bump bootstrap compiler to 1.57 Fixes https://github.com/rust-lang/rust/issues/90152 r? `@Mark-Simulacrum`
2021-10-24Auto merge of #90235 - matthiaskrgr:rollup-7pqtevk, r=matthiaskrgrbors-0/+1
Rollup of 6 pull requests Successful merges: - #89558 (Add rustc lint, warning when iterating over hashmaps) - #90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin) - #90155 (Fix alignment of method headings for scannability) - #90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn) - #90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call) - #90234 (Temporarily turn overflow checks off for rustc-rayon-core) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-24Auto merge of #85254 - cjgillot:reveal-mir, r=lcnrbors-1/+61
Normalize MIR with RevealAll before optimizations. Fixes #78442
2021-10-23update cfg(bootstrap)Pietro Albini-1/+0
2021-10-22Auto merge of #89893 - camsteffen:redundant-dump-enabled, r=matthewjasperbors-29/+7
Remove redundant dump_enabled check
2021-10-21Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obkYuki Okushi-7/+4
Remove hir::map::blocks and use FnKind instead The principal tool is `FnLikeNode`, which is not often used and can be easily implemented using `rustc_hir::intravisit::FnKind`.
2021-10-20Remove `box_alloc` from `Machine` trait.Gary Guo-7/+0
2021-10-19Replace FnLikeNode by FnKind.Camille GILLOT-7/+4
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-16/+8
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.