summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2022-01-06Rollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726Matthias Krüger-8/+7
Delay remaining `span_bug`s in drop elaboration This follows changes from #67967 and converts remaining `span_bug`s into delayed bugs, since for const items drop elaboration might be executed on a MIR which failed borrowck. Fixes #81708. Fixes #91816.
2022-01-04rename StackPopClean::None to RootRalf Jung-1/+1
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-7/+0
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #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
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-1/+1
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to - determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI) - impose further restrictions on whether caller and callee are consistent in how a given argument is passed I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around. I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;) One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way. r? `@oli-obk` `@eddyb` Fixes https://github.com/rust-lang/rust/issues/56166 Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-23Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obkMatthias Krüger-4/+4
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt` The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-22Delay remaining `span_bug`s in drop elaborationTomasz Miąsko-8/+7
This follows changes from #67967 and converts remaining `span_bug`s into delayed bugs, since for const items drop elaboration might be executed on a MIR which failed borrowck.
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-4/+4
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+2
Implement `Ord`, `PartialOrd` for SpanData
2021-12-20CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibilityRalf Jung-1/+1
2021-12-18Rollup merge of #91975 - cjgillot:noinline-generator, r=jackh726Matthias Krüger-8/+6
Move generator check earlier in inlining. Inlining into generator may create references to other generators. For instance, inlining `Pin::<&mut from_generator::GenFuture<[generator1]>>::new_unchecked` into `generator2`. This cross reference can then create cycles when computing inlining for `generator1`. In order to avoid this kind of surprises, we forbid all inlining into generators, and rely on LLVM to do the right thing. The existing `remove-zst-query-cycle` already ICEs in inline-mir mode, so we use it as test. Split from #91743.
2021-12-15Move generator check earlier in inlining.Camille GILLOT-8/+6
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-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-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