summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-06-24Update compiler/rustc_mir_transform/src/check_alignment.rsWesley Wiser-0/+1
2023-06-24Disable alignment checks on i686-pc-windows-msvcBen Kimock-0/+3
2023-06-03unique borrows are mutating useslcnr-3/+0
2023-05-29Exclude Rvalue::AddressOf for raw pointer deref alignment checksBen Kimock-0/+8
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-12/+21
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-12/+21
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-18/+0
2023-05-25Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearthbors-2/+2
Rollup of 5 pull requests Successful merges: - #111741 (Use `ObligationCtxt` in custom type ops) - #111840 (Expose more information in `get_body_with_borrowck_facts`) - #111876 (Roll compiler_builtins to 0.1.92) - #111912 (Use `Option::is_some_and` and `Result::is_ok_and` in the compiler ) - #111915 (libtest: Improve error when missing `-Zunstable-options`) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-24Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, ↵Manish Goregaokar-2/+2
r=petrochenkov Use `Option::is_some_and` and `Result::is_ok_and` in the compiler `.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable. This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24Rollup merge of #111121 - Zalathar:ra-false-positive, r=jackh726Matthias Krüger-2/+2
Work around `rust-analyzer` false-positive type errors rust-analyzer incorrectly reports two type errors in `debug.rs`: > expected &dyn Display, found &i32 > expected &dyn Display, found &i32 This is due to a known bug in r-a: (https://github.com/rust-lang/rust-analyzer/issues/11847). In these particular cases, changing `&0` to `&0i32` seems to be enough to avoid the bug.
2023-05-24Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiaskobors-30/+15
Preprocess and cache dominator tree Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344. That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree). This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache. Rebase of https://github.com/rust-lang/rust/pull/107157 cc `@tmiasko`
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-2/+2
2023-05-23Rollup merge of #111501 - WaffleLapkin:drivebycleanupuwu, r=oli-obkDylan DPC-32/+9
MIR drive-by cleanups Some random drive-by cleanups I did while working with MIR/THIR.
2023-05-20Don't inline functions with unsized argsJakob Degen-3/+12
2023-05-20Rollup merge of #111619 - cjgillot:profile-pass, r=WaffleLapkinDylan DPC-6/+6
Add timings for MIR passes to profiling report This will help identify which pass is responsible for a regression.
2023-05-17Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkinbors-13/+0
Stop turning transmutes into discriminant reads in mir-opt Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place. Having this "simplification" meant that similar-looking code actually did somewhat different things. For example, ```rust pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 { std::mem::transmute(x) } pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 { std::mem::transmute(x) } ``` in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18> ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 { %0 = icmp uge i8 %x, -1 %1 = icmp ule i8 %x, 1 %2 = or i1 %0, %1 call void `@llvm.assume(i1` %2) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 { %x = alloca i8, align 1 store i8 %0, ptr %x, align 1 %1 = load i8, ptr %x, align 1, !range !2, !noundef !3 ret i8 %1 } ``` Which feels too different when the original code is essentially identical. --- Aside: that example is different *after* optimizations too: ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 { %0 = add i8 %x, 1 %1 = icmp ult i8 %0, 3 tail call void `@llvm.assume(i1` %1) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 { ret i8 %0 } ``` so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
2023-05-17Rollup merge of #110930 - b-naber:normalize-elaborate-drops, r=cjgillotDylan DPC-1/+26
Don't expect normalization to succeed in elaborate_drops Fixes https://github.com/rust-lang/rust/issues/110682 This was exposed through the changes in https://github.com/rust-lang/rust/pull/109247, which causes more things to be inlined. Inlining can happen before monomorphization, so we can't expect normalization to succeed. In the elaborate_drops analysis we currently have [this call](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L278) to `normalize_erasing_regions`, which ICEs when normalization fails. The types are used to infer [whether the type needs a drop](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L374), where `needs_drop` itself [uses `try_normalize_erasing_regions`](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_middle/src/ty/util.rs#L1121). ~[`instance_mir`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.instance_mir) isn't explicit about whether it expects the instances corresponding to the `InstanceDef`s to be monomorphized (though I think in all other contexts the function is used post-monomorphization), so the use of `instance_mir` in inlining doesn't necessarily seem wrong to me.~
2023-05-17Simplify back-edge logic.Camille GILLOT-1/+1
2023-05-17Do not clone dominator tree for SSA analysis.Camille GILLOT-11/+8
2023-05-17Drive-by cleanup: `debug::term_type` => `TerminatorKind::name`Maybe Waffle-32/+9
2023-05-17Merge DominatorTree and Dominators.Camille GILLOT-17/+8
2023-05-17Cache dominators.Camille GILLOT-2/+5
2023-05-17Preprocess dominator tree to answer queries in O(1)Tomasz Miąsko-30/+24
2023-05-16Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obkbors-42/+50
Merge return place with other locals in CopyProp. This reintroduces a limited form of NRVO. r? wg-mir-opt
2023-05-16Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obkMatthias Krüger-2/+3
Handle error body in generator layout Fixes #111468 I feel like making this query return `Option<GeneratorLayout>` might be better but had some issues with that approach
2023-05-15Profile MIR passes.Camille GILLOT-6/+6
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-5/+5
2023-05-14Stop turning transmutes into discriminants in mir-optScott McMurray-13/+0
Partially reverts 109612, as after 109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.
2023-05-14Simplify implementation.Camille GILLOT-22/+16
2023-05-14Merge return place with other locals in CopyProp.Camille GILLOT-20/+34
2023-05-14Auto merge of #111517 - lukas-code:addr-of-mutate, r=tmiaskobors-17/+17
allow mutating function args through `&raw const` Fixes https://github.com/rust-lang/rust/issues/111502 by "turning off the sketchy optimization while we figure out if this is ok", like `@JakobDegen` said. The first commit in this PR removes some suspicious looking logic from the same method, but should have no functional changes, since it doesn't modify the `context` outside of the method. Best reviewed commit by commit. r? opsem
2023-05-13Handle error body when in generator layoutclubby789-2/+3
2023-05-13Do not ICE on deeply nested borrows.Camille GILLOT-2/+4
2023-05-13Iterate ReferencePropagation to fixpoint.Camille GILLOT-2/+4
2023-05-13Implement references VarDebugInfo.Camille GILLOT-0/+19
2023-05-13allow mutating function args through `&raw const`Lukas Markeffsky-5/+16
2023-05-12remove no-op logicLukas Markeffsky-13/+2
2023-05-12Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegenMatthias Krüger-30/+60
Verify copies of mutable pointers in 2 stages in ReferencePropagation Fixes #111422 In the first stage, we mark the copies as reborrows, to be checked later. In the second stage, we walk the reborrow chains to verify that all stages are fully replacable. The replacement itself mirrors the check, and iterates through the reborrow chain. r? ``````@RalfJung`````` cc ``````@JakobDegen``````
2023-05-11Rollup merge of #111432 - cjgillot:issue-111426, r=oli-obkMatthias Krüger-7/+13
Use visit_assign to detect SSA locals. I screwed up the logic in 3c43b61b870add2daddbd8e480477e5a8aa409c2. Fixes https://github.com/rust-lang/rust/issues/111426
2023-05-10Auto merge of #110820 - cjgillot:faster-dcp, r=oli-obkbors-17/+17
Optimize dataflow-const-prop place-tracking infra Optimization opportunities found while investigating https://github.com/rust-lang/rust/pull/110719 Computing places breadth-first ensures that we create short projections before deep projections, since the former are more likely to be propagated. The most relevant is the pre-computation of flooded places. Callgrind showed `flood_*` methods and especially `preorder_preinvoke` were especially hot. This PR attempts to pre-compute the set of `ValueIndex` that `preorder_invoke` would visit. Using this information, we make some `PlaceIndex` inaccessible when they contain no `ValueIndex`, allowing to skip computations for those places. cc `@jachris` as original author
2023-05-10Avoid shadowing.Camille GILLOT-2/+2
2023-05-10Do not see through copies of mutable pointers.Camille GILLOT-5/+6
2023-05-10Iteratively replace pointers.Camille GILLOT-25/+54
2023-05-10don't inline polymorphic adt instances whose fields contain projectionsb-naber-1/+26
in DropGlue.
2023-05-10Use visit_assign to detect SSA locals.Camille GILLOT-7/+13
2023-05-09Correct StorageLive comment.Camille GILLOT-2/+1
2023-05-09Only check storage liveness for direct projections.Camille GILLOT-6/+3
2023-05-09Do not check StorageLive dominates address-taking.Camille GILLOT-41/+75
2023-05-09Only check that StorageLive dominates address-taking.Camille GILLOT-4/+1
2023-05-09Explicit performance concern.Camille GILLOT-2/+2