about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
2023-03-11`MaybeUninit::assume_init_read` should have `noundef` load metadataScott McMurray-0/+24
I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Turned out to be a more general problem as `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. This PR lowers `ptr::read(p)` to `copy *p` in MIR, which fortuitiously also improves the IR we give to LLVM for things like `mem::replace`.
2023-03-11Use ensure_with_value in a few more places.Camille GILLOT-1/+1
2023-03-11Make the check for cache opt-in.Camille GILLOT-5/+5
2023-03-10Rollup merge of #108902 - lcnr:do-while-sus, r=davidtwco,NilstriebMatthias Krüger-20/+20
no more do while :<
2023-03-09Bug on PlaceMention in dest-prop.Camille GILLOT-2/+3
2023-03-09Pacify tidy.Camille GILLOT-2/+2
2023-03-09Ignore AscribeUserType in unsafeck to avoid duplicate diagnostics.Camille GILLOT-1/+3
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-1/+12
2023-03-09no more do whilelcnr-20/+20
2023-03-09Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgrbors-159/+16
Rollup of 8 pull requests Successful merges: - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous) - #108759 (1.41.1 supported 32-bit Apple targets) - #108839 (Canonicalize root var when making response from new solver) - #108856 (Remove DropAndReplace terminator) - #108882 (Tweak E0740) - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap) - #108911 (Improve rustdoc-gui/tester.js code a bit) - #108916 (Remove an unused return value in `rustc_hir_typeck`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-09Auto merge of #108178 - cjgillot:ssa-deref, r=oli-obkbors-16/+40
Do not consider `&mut *x` as mutating `x` in `CopyProp` This PR removes an unfortunate overly cautious case from the current implementation. Found by https://github.com/rust-lang/rust/pull/105274 cc `@saethlin`
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-159/+16
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08Remove useless parameter to operand_from_scalar.Camille GILLOT-14/+5
2023-03-08Make comment more explicit.Camille GILLOT-2/+4
2023-03-08Separate checking rvalue from evaluation.Camille GILLOT-113/+104
2023-03-08Recurse into statement before applying its effect.Camille GILLOT-4/+8
2023-03-08Refactor tracking of writes.Camille GILLOT-72/+58
2023-03-08Remove OnlyPropagateInto.Camille GILLOT-31/+8
2023-03-08Only assign value in remove_const.Camille GILLOT-15/+7
2023-03-08Do not track span in ConstProp.Camille GILLOT-30/+9
2023-03-08Simplify visit_statement.Camille GILLOT-65/+61
2023-03-08Create visit_block_data for const-prop-lint.Camille GILLOT-5/+5
2023-03-08Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholkbors-12/+10
Do not implement HashStable for HashSet (MCP 533) This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order. The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-08Only compute the crate hash when necessary.Nicholas Nethercote-1/+1
The crate hash is needed: - if debug assertions are enabled, or - if incr. comp. is enabled, or - if metadata is being generated, or - if `-C instrumentation-coverage` is enabled. This commit avoids computing the crate hash when these conditions are all false, such as when doing a release build of a binary crate. It uses `Option` to store the hashes when needed, rather than computing them on demand, because some of them are needed in multiple places and computing them on demand would make compilation slower. The commit also removes `Owner::hash_without_bodies`. There is no benefit to pre-computing that one, it can just be done in the normal fashion.
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-159/+16
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-06Rollup merge of #108786 - saethlin:free-regions-check, r=oli-obkMatthias Krüger-6/+0
Check for free regions in MIR validation This turns https://github.com/rust-lang/rust/issues/108720 into a MIR validation failure that will reproduce without debug-assertions enabled. ``` error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:296 ~ futures_util[3805]::future::future::remote_handle::{impl#3}::poll), const_param_did: None }) (after pass ScalarReplacementOfAggregates) at bb0[0]: Free regions in optimized runtime-post-cleanup MIR --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/remote_handle.rs:96:13 | 96 | let this = self.project(); | ^^^^ ```
2023-03-06Auto merge of #108787 - cjgillot:sroa-lifetime, r=compiler-errorsbors-3/+5
Erase regions even when failing to normalize type in MIR opts The first commit just moves the tests around. Fixes https://github.com/rust-lang/rust/issues/108720 cc `@saethlin`
2023-03-05Rollup merge of #108764 - cjgillot:dpm-adapt, r=compiler-errorsMatthias Krüger-6/+8
Tweaks to -Zdrop-tracking-mir Split from https://github.com/rust-lang/rust/pull/107421 3 commits: 1 diagnostic improvement and 2 ICEs.
2023-03-05Check for free regions in MIR validationBen Kimock-6/+0
2023-03-05Erase lifetimes in SROA.Camille GILLOT-3/+5
2023-03-05drop_tracking_mir: avoid good path bug.Camille GILLOT-6/+8
2023-03-05Auto merge of #107844 - Zeegomo:no-drop-and-rep, r=cjgillotbors-5/+14
Desugaring of drop and replace at MIR build This commit desugars the drop and replace deriving from an assignment at MIR build, avoiding the construction of the `DropAndReplace` terminator (which will be removed in a following PR). In order to retain the same error messages for replaces a new `DesugaringKind::Replace` variant is introduced. The changes in the borrowck are also useful for future work in moving drop elaboration before borrowck, as no `DropAndReplace` would be present there anymore. Notes on test diffs: * `tests/ui/borrowck/issue-58776-borrowck-scans-children`: the assignment deriving from the desugaring kills the borrow. * `tests/ui/async-await/async-fn-size-uninit-locals.rs`, `tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir`, `tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir`: drop elaboration generates (or reads from) a useless drop flag due to an issue with the dataflow analysis. Will be fixed independently by https://github.com/rust-lang/rust/pull/106430. See https://github.com/rust-lang/rust/pull/104488 for more context
2023-03-03Desugars drop and replace at MIR buildGiacomo Pasini-5/+14
This commit desugars the drop and replace deriving from an assignment at MIR build, avoiding the construction of the DropAndReplace terminator (which will be removed in a followign PR) In order to retain the same error messages for replaces a new DesugaringKind::Replace variant is introduced.
2023-03-03Match unmatched backticks in comments in compiler/est31-4/+7
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-03-01Remove last instances of HashSet in query result types.Michael Woerister-12/+10
2023-02-27Do not grow `assignment_order` needlessly.Camille GILLOT-2/+5
2023-02-27Special case deref projections in SsaVisitor.Camille GILLOT-14/+35
2023-02-27Unify all validity check intrinsicsNilstrieb-12/+4
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-27Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger-35/+22
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
2023-02-25Auto merge of #108250 - nnethercote:rename-interner-funcs, r=compiler-errorsbors-25/+23
Rename interner funcs This PR cleans up some inconsistencies in interner naming. Best reviewed one commit at a time. r? `@compiler-errors`
2023-02-24Rename many interner functions.Nicholas Nethercote-25/+23
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Unify validity checks into a single queryNilstrieb-35/+22
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-23Remove dead unwinds before drop elaborationTomasz Miąsko-18/+39
As a part of drop elaboration, we identify dead unwinds, i.e., unwind edges on a drop terminators which are known to be unreachable, because there is no need to drop anything. Previously, the data flow framework was informed about the dead unwinds, and it assumed those edges are absent from MIR. Unfortunately, the data flow framework wasn't consistent in maintaining this assumption. In particular, if a block was reachable only through a dead unwind edge, its state was propagated to other blocks still. This became an issue in the context of change removes DropAndReplace terminator, since it introduces initialization into cleanup blocks. To avoid this issue, remove unreachable unwind edges before the drop elaboration, and elaborate only blocks that remain reachable.
2023-02-23Rollup merge of #108208 - cjgillot:flood-enum, r=oli-obkMatthias Krüger-7/+18
Correctly handle aggregates in DataflowConstProp The previous implementation from https://github.com/rust-lang/rust/pull/107411 flooded target of an aggregate assignment with `Bottom`, corresponding to the `deinit` that the interpreter does. As a consequence, when assigning `target = Enum::Variant#i(...)` all the `(target as Variant#j)` were at `Bottom` while they should have been `Top`. This PR replaces that flooding with `Top`. Aside, it corrects a second bug where the wrong place would be used to assign to enum variant fields, resulting to nothing happening. Fixes https://github.com/rust-lang/rust/issues/108166
2023-02-22Remove type-traversal trait aliasesAlan Egerton-4/+6
2023-02-22Rollup merge of #108246 - saethlin:instcombine-redundant-casts, ↵Guillaume Gomez-0/+9
r=compiler-errors Add an InstCombine for redundant casts `@rustbot` label +A-mir-opt
2023-02-20Remove use_ecx.Camille GILLOT-60/+37
2023-02-20Merge if-let and match.Camille GILLOT-67/+63
2023-02-20Move state fixup into a different method.Camille GILLOT-6/+6