about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2022-09-13address reviewb-naber-1/+1
2022-09-13use ty::Unevaluated<'tcx, ()> in type systemb-naber-19/+28
2022-09-11minor fixups as per PR feedbackAndrew Cann-3/+2
2022-09-11Add some comments to generator clone shim codeAndrew Cann-0/+12
2022-09-11Apply formatting fixesAndrew Cann-22/+6
2022-09-11implement Copy/Clone for generatorsAndrew Cann-32/+97
2022-09-07Rollup merge of #101525 - eltociear:patch-16, r=cjgillotMatthias Krüger-2/+2
Fix typo in pass_manager.rs overriden -> overridden
2022-09-07Fix typo in pass_manager.rsIkko Ashimine-2/+2
overriden -> overridden
2022-09-06Generalize the Assume intrinsic statement to a general Intrinsic statementOli Scherer-27/+25
2022-09-06Lower the assume intrinsic to a MIR statementOli Scherer-0/+22
2022-09-04remap mir before running optimization passesDeadbeef-4/+7
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-3/+65
2022-08-30Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obkbors-84/+108
Rework definition of MIR phases to more closely reflect semantic concerns Implements most of rust-lang/compiler-team#522 . I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
2022-08-30Simplify pass manager's `run_passes` logicJakob Degen-29/+19
2022-08-30Refactor MIR phasesJakob Degen-56/+90
2022-08-30Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrumbors-0/+1
Revert let_chains stabilization This is the revert against master, the beta revert was already done in #100538. Bumps the stage0 compiler which already has it reverted.
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Rollup merge of #100239 - RalfJung:const-prop-uninit, r=oli-obkDylan DPC-32/+53
remove an ineffective check in const_prop Based on https://github.com/rust-lang/rust/pull/100043, only the last two commits are new. ConstProp has a special check when reading from a local that prevents reading uninit locals. However, if that local flows into `force_allocation`, then no check fires and evaluation proceeds. So this check is not really effective at preventing accesses to uninit locals. With https://github.com/rust-lang/rust/pull/100043, `read_immediate` and friends always fail when reading uninit locals, so I don't see why ConstProp would need a separate check. Thus I propose we remove it. This is needed to be able to do https://github.com/rust-lang/rust/pull/100085.
2022-08-29Rollup merge of #101111 - saethlin:better-fnentry-spans, r=RalfJungMatthias Krüger-11/+8
Use the declaration's SourceInfo for FnEntry retags, not the outermost This addresses a long-standing `// FIXME` in the pass that adds retags. The changes to Miri's UI tests will look like this: ``` --> $DIR/aliasing_mut1.rs:LL:CC | LL | pub fn safe(_x: &mut i32, _y: &mut i32) {} < | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID > | ^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID | ``` r? ````@RalfJung````
2022-08-29Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obkMatthias Krüger-65/+64
Replace `Body::basic_blocks()` with field access Since the refactoring in #98930, it is possible to borrow the basic blocks independently from other parts of MIR by accessing the `basic_blocks` field directly. Replace unnecessary `Body::basic_blocks()` method with a direct field access, which has an additional benefit of borrowing the basic blocks only.
2022-08-28Use the declaration's SourceInfo for FnEntry retags, not the outermostBen Kimock-11/+8
2022-08-27remove a now-useless machine hookRalf Jung-9/+0
2022-08-27remove an ineffective check in const_propRalf Jung-24/+54
2022-08-27Rollup merge of #101057 - cjgillot:one-fn-sig, r=compiler-errorsYuki Okushi-1/+1
Merge implementations of HIR fn_decl and fn_sig.
2022-08-26Merge implementations of HIR fn_decl and fn_sig.Camille GILLOT-1/+1
2022-08-26make read_immediate error immediately on uninit, so ImmTy can carry ↵Ralf Jung-33/+22
initialized Scalar
2022-08-26Replace `Body::basic_blocks()` with field accessTomasz Miąsko-65/+64
2022-08-26Rollup merge of #100034 - tmiasko:elaborate-box-derefs, r=oli-obkYuki Okushi-102/+9
Elaborate all box dereferences in `ElaborateBoxDerefs` so that it is the only pass responsible for elaboration, instead of splitting this responsibility between the `StateTransform` and `ElaborateBoxDerefs`.
2022-08-25Elaborate all box dereferences in `ElaborateBoxDerefs`Tomasz Miąsko-102/+9
so that it is the only pass responsible for elaboration, instead of splitting this responsibility between the `StateTransform` and `ElaborateBoxDerefs`.
2022-08-25Auto merge of #100571 - cjgillot:mir-cost-visit, r=compiler-errorsbors-92/+222
Check projection types before inlining MIR Fixes https://github.com/rust-lang/rust/issues/100550 I'm very unhappy with this solution, having to duplicate MIR validation code, but at least it removes the ICE. r? `@compiler-errors`
2022-08-24Auto merge of #99946 - tmiasko:elide-storage-makers, r=oli-obkbors-29/+8
Elide superfluous storage markers Follow the existing strategy of omitting the storage markers for temporaries introduced for internal usage when elaborating derefs and deref projections. Those temporaries are simple scalars which are used immediately after being defined and never have their address taken. There is no benefit from storage markers from either liveness analysis or code generation perspective.
2022-08-23Fix typo in UnreachablePropnils-1/+1
2022-08-23Elide storage markers for internal locals when inliningTomasz Miąsko-2/+6
2022-08-23Elide storage markers when elaborating deref projectionsTomasz Miąsko-19/+1
2022-08-23Elide storage markers when elaborating box derefsTomasz Miąsko-8/+1
2022-08-21Enable UnreachablePropagation under mir-opt-level >= 2Nilstrieb-3/+2
It was disabled because of pathological behaviour of LLVM in some benchmarks. As of #77680, this has been fixed. The problem there was that it caused pessimizations in some cases. These have now been fixed as well.
2022-08-21UnreachableProp: Preserve unreachable branches for multiple targetsNilstrieb-23/+48
Before, UnreachablePropagation removed all unreachable branches. This was a pessimization, as it removed information about reachability that was used later in the optimization pipeline. For example, this code ```rust pub enum Two { A, B } pub fn identity(x: Two) -> Two { match x { Two::A => Two::A, Two::B => Two::B, } } ``` basically has `switchInt() -> [0: 0, 1: 1, otherwise: unreachable]` for the match. This allows it to be transformed into a simple `x`. If we remove the unreachable branch, the transformation becomes illegal.
2022-08-21Also validate types before inlining.Camille GILLOT-0/+100
2022-08-21Refactor cost computation as a visitor.Camille GILLOT-92/+122
2022-08-19Rollup merge of #100522 - cjgillot:inline-polymorphic-recursion, r=tmiaskoDylan DPC-4/+9
Only check the `DefId` for the recursion check in MIR inliner. The current history check compares `Instance`s, so it cannot detect cases of polymorphic recursion where `Substs` change. This PR makes it so we only compare `DefId`s, ignoring any change in `Substs`. According to https://github.com/rust-lang/rust/pull/100522#issuecomment-1214769757, in practice only very few inlining decisions change. Fixes https://github.com/rust-lang/rust/issues/100476
2022-08-19Rollup merge of #100081 - RalfJung:unused-unsafe-in-unsafe-fn, r=jackh726Dylan DPC-71/+17
never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn) Judging from https://github.com/rust-lang/rust/issues/71668#issuecomment-1200317370 the consensus nowadays seems to be that we should never consider an unsafe block unused if it was required with `deny(unsafe_op_in_unsafe_fn)`, no matter whether that lint is actually enabled or not. So let's adjust rustc accordingly. The first commit does the change, the 2nd does some cleanup.
2022-08-17Ignore substs when checking inlining history.Camille GILLOT-4/+9
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-12Rollup merge of #100229 - RalfJung:extra-const-ub-checks, r=lcnrDylan DPC-0/+12
add -Zextra-const-ub-checks to enable more UB checking in const-eval Cc https://github.com/rust-lang/rust/issues/99923 r? `@oli-obk`
2022-08-11Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillotMatthias Krüger-9/+1
Simplify visitors By removing some unused arguments. r? `@cjgillot`
2022-08-11Rollup merge of #100192 - tmiasko:rm-duplicated-locals, r=nagisaDylan DPC-8/+0
Remove duplicated temporaries creating during box derefs elaboration Temporaries created with `MirPatch::new_temp` will be declared after patch application. Remove manually created duplicate declarations. Removing duplicates exposes another issue. Visitor elaborates terminator twice and attempts to access new, but not yet available, local declarations. Remove duplicated call to `visit_terminator`. Extracted from #99946.
2022-08-11Simplify `rustc_hir::intravisit::Visitor::visit_variant_data`.Nicholas Nethercote-9/+1
It has four arguments that are never used. This avoids lots of argument passing in functions that feed into `visit_variant_data`.
2022-08-09dont rely on old macro-in-trait-impl bugRalf Jung-0/+12
2022-08-09Add option to `mir::MutVisitor` to not invalidate CFG.Jakob Degen-9/+9
This also applies that option to some uses of the visitor
2022-08-06Remove duplicated temporaries creating during box derefs elaborationTomasz Miąsko-8/+0
Temporaries created with `MirPatch::new_temp` will be declared after patch application. Remove manually created duplicate declarations. Removing duplicates exposes another issue. Visitor elaborates terminator twice and attempts to access new, but not yet available, local declarations. Remove duplicated call to `visit_terminator`.