about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2022-12-08validate: use the correct reveal during optslcnr-0/+8
2022-12-06Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiserMatthias Krüger-1/+1
Put all cached values into a central struct instead of just the stable hash cc `@nnethercote` this allows re-use of the type for Predicate without duplicating all the logic for the non-hash cached fields
2022-12-06make retagging work even with 'unstable' placesRalf Jung-1/+1
2022-12-02Use zero based indexing for pass_countOli Scherer-2/+2
2022-12-02Remove an impl and replace its only use with a method callOli Scherer-6/+0
2022-12-01Create `format_args` as late as possibleOli Scherer-17/+15
2022-12-01Remove needless `Cow`Oli Scherer-6/+2
2022-12-01Don't go through the formatting infrastructure just to get the name of a phaseOli Scherer-24/+14
2022-11-30Update documentationOli Scherer-1/+1
2022-11-29Auto merge of #105012 - WaffleLapkin:into, r=oli-obkbors-2/+1
Make `tcx.mk_const` more permissive wrt `kind` argument (`impl Into`) r? `@oli-obk` you've asked for this >:)
2022-11-28Simplify calls to `tcx.mk_const`Maybe Waffle-2/+1
`mk_const(ty::ConstKind::X(...), ty)` can now be simplified to `mk_cosnt(..., ty)`. I searched with the following regex: \mk_const\([\n\s]*(ty::)?ConstKind\ I've left `ty::ConstKind::{Bound, Error}` as-is, they seem clearer this way.
2022-11-28Rollup merge of #104933 - RalfJung:interpret-partial-ord, r=oli-obkMatthias Krüger-7/+7
interpret: remove PartialOrd from a bunch of types that do not have or need a sensible order r? `@oli-obk`
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-2/+2
2022-11-26interpret: remove PartialOrd from a bunch of types that do not have or need ↵Ralf Jung-7/+7
a sensible order
2022-11-25Add empty ConstKind::Abstractkadmin-4/+5
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-23use no type in ProjectionElem::Field for PlaceBuilder::UpVarb-naber-13/+38
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-8/+8
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-21Remove an unnecessary query + subst roundOli Scherer-1/+1
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-8/+8
2022-11-20Rollup merge of #104564 - RalfJung:either, r=oli-obkMatthias Krüger-8/+12
interpret: use Either over Result when it is not representing an error condition r? `@oli-obk`
2022-11-18interpret: use Either over Result when it is not representing an error conditionRalf Jung-8/+12
2022-11-17fix a typoRalf Jung-1/+1
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-6/+4
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-20/+9
2022-11-15Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obkbors-0/+64
Perform simple scalar replacement of aggregates (SROA) MIR opt This is a re-open of https://github.com/rust-lang/rust/pull/85796 I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR. This pass replaces plain field accesses by simple locals when possible. To be eligible, the replaced locals: - must not be enums or unions; - must not be used whole; - must not have their address taken. The storage and deinit statements are duplicated on each created local. cc `@tmiasko` who reviewed the former version of this PR.
2022-11-15Introduce composite debuginfo.Camille GILLOT-0/+64
2022-11-15Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obkbors-799/+990
interpret: support for per-byte provenance Also factors the provenance map into its own module. The third commit does the same for the init mask. I can move it in a separate PR if you prefer. Fixes https://github.com/rust-lang/miri/issues/2181 r? `@oli-obk`
2022-11-15Auto merge of #101168 - jachris:dataflow-const-prop, r=oli-obkbors-4/+12
Add new MIR constant propagation based on dataflow analysis The current constant propagation in `rustc_mir_transform/src/const_prop.rs` fails to handle many cases that would be expected from a constant propagation optimization. For example: ```rust let x = if true { 0 } else { 0 }; ``` This pull request adds a new constant propagation MIR optimization pass based on the existing dataflow analysis framework. Since most of the analysis is not unique to constant propagation, a generic framework has been extracted. It works on top of the existing framework and could be reused for other optimzations. Closes #80038. Closes #81605. ## Todo ### Essential - [x] [Writes to inactive enum variants](https://github.com/rust-lang/rust/pull/101168#pullrequestreview-1089493974). Resolved by rejecting the registration of places with downcast projections for now. Could be improved by flooding other variants if mutable access to a variant is observed. - [X] Handle [`StatementKind::CopyNonOverlapping`](https://github.com/rust-lang/rust/pull/101168#discussion_r957774914). Resolved by flooding the destination. - [x] Handle `UnsafeCell` / `!Freeze` correctly. - [X] Overflow propagation of `CheckedBinaryOp`: Decided to not propagate if overflow flag is `true` (`false` will still be propagated) - [x] More documentation in general. - [x] Arguments for correctness, documentation of necessary assumptions. - [x] Better performance, or alternatively, require `-Zmir-opt-level=3` for now. ### Extra - [x] Add explicit unreachability, i.e. upgrading the lattice from $\mathbb{P} \to \mathbb{V}$ to $\set{\bot} \cup (\mathbb{P} \to \mathbb{V})$. - [x] Use storage statements to improve precision. - [ ] Consider opening issue for duplicate diagnostics: https://github.com/rust-lang/rust/pull/101168#issuecomment-1276609950 - [ ] Flood moved-from places with $\bot$ (requires some changes for places with tracked projections). - [ ] Add downcast projections back in. - [ ] [Algebraic simplifications](https://github.com/rust-lang/rust/pull/101168#discussion_r957967878) (possibly with a shared API; done by old const prop). - [ ] Propagation through slices / arrays. - [ ] Find other optimizations that are done by old `const_prop.rs`, but not by this one.
2022-11-14assert that we are (de)seiralizing ProvenanceMap correctlyRalf Jung-13/+13
2022-11-14Remove redundant graphviz escapingJannis Christopher Köhl-4/+3
2022-11-14Manually implement `Encodable` for ProvenanceMap to avoid serializing an ↵Oli Scherer-1/+16
always-none option
2022-11-13Store a LocalDefId in hir::GenericParam.Camille GILLOT-6/+4
2022-11-13fix some typos in commentscui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-11Rollup merge of #103960 - AndyJado:var_path_only_diag, r=davidtwcoManish Goregaokar-0/+1
piece of diagnostic migrate r? `@davidtwco`
2022-11-10Use const_error_with_guaranteed moreMichael Goulet-2/+5
2022-11-09var_subdiag refinementAndyJado-0/+1
trim old
2022-11-09another optimization attemptRalf Jung-66/+83
2022-11-08Add support for custom MIR parsingJakob Degen-0/+59
2022-11-08another attempt at performance improvementsRalf Jung-23/+26
2022-11-07less unsupported errors in Miri, and clarifying commentsRalf Jung-9/+9
2022-11-07Only assume Stacked Borrows if -Zunsound-mir-opts is givenJannis Christopher Köhl-0/+9
2022-11-07try to make things faster when only ptr provenance can existRalf Jung-5/+17
2022-11-06make uninit_mask a unit testRalf Jung-1/+22
2022-11-06move InitMask to its own moduleRalf Jung-592/+578
2022-11-06dont debug-print allocations, that's too verboseRalf Jung-4/+4
2022-11-06interpret: support for per-byte provenanceRalf Jung-191/+328
2022-11-04Refactor tcx mk_const parameters.Mateusz-4/+2
2022-10-31Use `br` instead of `switch` in more cases.Nicholas Nethercote-0/+5
`codegen_switchint_terminator` already uses `br` instead of `switch` when there is one normal target plus the `otherwise` target. But there's another common case with two normal targets and an `otherwise` target that points to an empty unreachable BB. This comes up a lot when switching on the tags of enums that use niches. The pattern looks like this: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 switch i64 %_6, label %bb3 [ i64 0, label %bb4 i64 1, label %bb2 ] bb3: ; preds = %bb1 unreachable ``` This commit adds code to convert the `switch` to a `br`: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 %6 = icmp eq i64 %_6, 0 br i1 %6, label %bb4, label %bb2 bb3: ; No predecessors! unreachable ``` This has a surprisingly large effect on compile times, with reductions of 5% on debug builds of some crates. The reduction is all due to LLVM taking less time. Maybe LLVM is just much better at handling `br` than `switch`. The resulting code is still suboptimal. - The `icmp`, `select`, `icmp` sequence is silly, converting an `i1` to an `i64` and back to an `i1`. But with the current code structure it's hard to avoid, and LLVM will easily clean it up, in opt builds at least. - `bb3` is usually now truly dead code (though not always, so it can't be removed universally).
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-3/+3
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-27Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"Michael Goulet-11/+7
This reverts commit a6b5f95fb028f9feb4a2957c06b35035be2c6155.