about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
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-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
2023-05-09Do not consider borrowed Freeze locals as SSA.Camille GILLOT-29/+34
2023-05-09Implement SSA-based reference propagation.Camille GILLOT-43/+417
2023-05-09Extract handle_set_discriminant.Camille GILLOT-15/+15
2023-05-09Make HasTop and HasBottom consts.Camille GILLOT-2/+2
2023-05-08Auto merge of #111358 - compiler-errors:rollup-yv27vrp, r=compiler-errorsbors-198/+384
Rollup of 6 pull requests Successful merges: - #104070 (Prevent aborting guard from aborting the process in a forced unwind) - #109410 (Introduce `AliasKind::Inherent` for inherent associated types) - #111004 (Migrate `mir_transform` to translatable diagnostics) - #111118 (Suggest struct when we get colon in fileds in enum) - #111170 (Diagnostic args are still args if they're documented) - #111354 (Fix miscompilation when calling default methods on `Future`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-08Auto merge of #111007 - JakobDegen:nrvo, r=tmiaskobors-1/+2
Disable nrvo mir opt See #111005 and #110902 . The ICE can definitely be hit on stable, the miscompilation I'm not sure about. The pass makes some pretty sketchy assumptions though, and we should not have it on while that's the case. I'm not going to work on actually fixing this, it's probably not excessively difficult though. r? rust-lang/mir-opt
2023-05-08Rollup merge of #111004 - clubby789:migrate-mir-transform, r=oli-obkMichael Goulet-198/+384
Migrate `mir_transform` to translatable diagnostics cc #100717
2023-05-08Auto merge of #110824 - cjgillot:const-prop-index, r=JakobDegen,oli-obkbors-0/+18
ConstProp into PlaceElem::Index. Noticed this while looking at keccak output MIR. This pass aims to replace `ProjectionElem::Index` with `ProjectionElem::ConstantIndex` during ConstProp. r? `@ghost`
2023-05-08Disable nrvo mir optJakob Degen-1/+2
2023-05-08Rollup merge of #110297 - kylematsuda:earlybinder_tcx_subst, r=BoxyUwUDylan DPC-5/+13
Make `(try_)subst_and_normalize_erasing_regions` take `EarlyBinder` Changes `subst_and_normalize_erasing_regions` and `try_subst_and_normalize_erasing_regions` to take `EarlyBinder<T>` instead of `T`. (related to #105779) This was suggested by `@BoxyUwU` in https://github.com/rust-lang/rust/pull/107753#discussion_r1105828139. After changing `type_of` to return `EarlyBinder`, there were several places where the binder was immediately skipped to call `tcx.subst_and_normalize_erasing_regions`, only for the binder to be reconstructed inside of that method. r? `@BoxyUwU`
2023-05-07Propagate PlaceElem::Index.Camille GILLOT-0/+18
2023-05-06make subst_mir take EarlyBinderKyle Matsuda-3/+7
2023-05-06use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda-2/+6
2023-05-06Rename InstCombine to InstSimplifyBen Kimock-29/+29
2023-05-04Reject borrows of projections in ConstProp.Camille GILLOT-5/+15
2023-05-04Rollup merge of #110826 - cjgillot:place-mention-use, r=JakobDegen,lcnrMatthias Krüger-0/+1
Make PlaceMention a non-mutating use. Fixes https://github.com/rust-lang/rust/issues/110781 r? `@JakobDegen` I don't agree with your statement in https://github.com/rust-lang/rust/issues/110781#issuecomment-1520841434. I suggest that we start fixing `PlaceContext` to be accurate enough for optimizations to use it. This structure is very convenient to use in visitors, and we perhaps have an opportunity to make it less of a footgun.
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-5/+4
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Migrate `mir_transform` to translatable diagnosticsclubby789-198/+384
2023-05-02Auto merge of #111082 - saethlin:box-assertkind, r=saethlinbors-3/+3
Box AssertKind r? `@nnethercote` this feels like your kind of thing I want to add a new variant to `AssertKind` that needs 3 operands, and that ends up breaking a bunch of size assertions. So... what if we go the opposite direction first; shrinking `AssertKind` by boxing it?
2023-05-02Auto merge of #109521 - tmiasko:const-prop-validation, r=wesleywiserbors-25/+3
Don't validate constants in const propagation Validation is neither necessary nor desirable. The constant validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
2023-05-01Box AssertKindBen Kimock-3/+3
2023-05-01Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgrbors-4/+1
Rollup of 7 pull requests Successful merges: - #109540 (std docs: edit `PathBuf::set_file_name` example) - #110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`) - #110987 (update wasi_clock_time_api ref.) - #111038 (Leave promoteds untainted by errors when borrowck fails) - #111042 (Add `#[no_coverage]` to the test harness's `fn main`) - #111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined) - #111065 (Explicitly document how Send and Sync relate to references) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-30Codegen fewer instructions in `mem::replace`Scott McMurray-0/+23
2023-04-30Leave promoteds untainted by errors when borrowck failsTomasz Miąsko-4/+1
Previously, when borrowck failed it would taint all promoteds within the MIR body. An attempt to evaluated the promoteds would subsequently fail with spurious "note: erroneous constant used". For example: ```console ... note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:9 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:14 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:19 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:24 | 7 | a = &0 * &1 * &2 * &3; | ^^ ``` Borrowck failure doesn't indicate that there is anything wrong with promoteds. Leave them untainted.
2023-04-30Rollup merge of #110973 - bindsdev:packed-struct-ref-diagnostic-note, ↵Matthias Krüger-2/+5
r=compiler-errors improve error notes for packed struct reference diagnostic Addresses #110199
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-0/+1
2023-04-28improve error notes for packed struct reference diagnosticbindsdev-2/+5
2023-04-28Make drop_flags an IndexVec.Camille GILLOT-7/+8
2023-04-27Auto merge of #110882 - BoxyUwU:rename-some-ty-flags, r=compiler-errorsbors-5/+5
rename `NEEDS_SUBST` and `NEEDS_INFER` implements rust-lang/compiler-team#617
2023-04-27rename `needs_subst` to `has_param`Boxy-5/+5
2023-04-27Auto merge of #110728 - cjgillot:no-false-optes, r=oli-obkbors-38/+46
Do not bother optimizing impossible functions. This is currently checked by `ConstProp`, but I see no reason to restrict it to ConstProp only.
2023-04-27Remove workaround for CastKind::Transmute from const propTomasz Miąsko-10/+0
Since constants are no longer validated before propagation the workaround is obsolete. Remove it.
2023-04-27Don't validate constants before propagationTomasz Miąsko-15/+3
Validation is neither necessary nor desirable. The validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
2023-04-26Auto merge of #110822 - scottmcm:lower-offset-to-mir, r=compiler-errorsbors-0/+17
Lower `intrinsics::offset` to `mir::BinOp::Offset` They're [semantically the same](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html#variant.BinaryOp), so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-26Auto merge of #97368 - tmandry:coverage-underflow, r=jyn514bors-1/+1
coverage: Don't underflow column number I noticed this when running coverage on a debug build of rustc. There may be other places that do this but I'm just fixing the one I hit. r? `@wesleywiser` `@richkadel`
2023-04-25Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray-0/+17
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-1/+1
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Move unstatisfaction check earlier.Camille GILLOT-50/+44
2023-04-24Fully clear the body.Camille GILLOT-11/+13
2023-04-25Rollup merge of #110685 - cjgillot:clean-dcp, r=oli-obkYuki Okushi-73/+52
Some cleanups to DataflowConstProp Mostly moving code around and short-circuiting useless cases.
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-19/+19
2023-04-24Rollup merge of #110714 - cjgillot:reveal-consts, r=oli-obkMatthias Krüger-9/+23
Normalize types and consts in MIR opts. Some passes were using a non-RevealAll param_env, which is needlessly restrictive in mir-opts. As a drive-by, we normalize all constants, since just normalizing their types is not enough.