summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src
AgeCommit message (Collapse)AuthorLines
2022-05-10only_local: always check for misuselcnr-34/+21
2022-05-08Use sparse representation of switch sourcesTomasz Miąsko-1/+1
to avoid quadratic space overhead
2022-05-08Avoid constructing switch sources unless necessaryTomasz Miąsko-3/+4
Switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed. Delay the computation until we know that switch sources are indeed required and avoid the computation otherwise.
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-36/+36
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-02fix most compiler/ doctestsElliot Roberts-36/+36
2022-04-30Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSetTomasz Miąsko-36/+62
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-25/+14
2022-04-11Add new `Deinit` statement kindJakob Degen-3/+4
2022-03-30Spellchecking compiler commentsYuri Astrakhan-3/+3
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-27NitDylan MacKenzie-3/+1
2022-03-26Address review commentsSamuel E. Moelius III-7/+11
* Add lazily computed `switch_sources` data structure * Don't assume a target has only one associated value
2022-03-24Implement `apply_switch_int_edge_effects` for backward analysesSamuel E. Moelius III-8/+56
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-21/+22
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-4/+4
2022-02-26Rollup merge of #94087 - tmiasko:rm-ignore-borrow-on-drop, r=jackh726Matthias Krüger-34/+11
Remove unused `unsound_ignore_borrow_on_drop`
2022-02-26Rollup merge of #93870 - tmiasko:const-precise-live-drops-with-coverage, ↵Matthias Krüger-15/+18
r=ecstatic-morse Fix switch on discriminant detection in a presence of coverage counters Fixes #93848. r? ``@ecstatic-morse``
2022-02-23Auto merge of #93984 - nnethercote:ChunkedBitSet, r=Mark-Simulacrumbors-33/+121
Introduce `ChunkedBitSet` and use it for some dataflow analyses. This reduces peak memory usage significantly for some programs with very large functions. r? `@ghost`
2022-02-23Introduce `ChunkedBitSet` and use it for some dataflow analyses.Nicholas Nethercote-33/+121
This reduces peak memory usage significantly for some programs with very large functions, such as: - `keccak`, `unicode_normalization`, and `match-stress-enum`, from the `rustc-perf` benchmark suite; - `http-0.2.6` from crates.io. The new type is used in the analyses where the bitsets can get huge (e.g. 10s of thousands of bits): `MaybeInitializedPlaces`, `MaybeUninitializedPlaces`, and `EverInitializedPlaces`. Some refactoring was required in `rustc_mir_dataflow`. All existing analysis domains are either `BitSet` or a trivial wrapper around `BitSet`, and access in a few places is done via `Borrow<BitSet>` or `BorrowMut<BitSet>`. Now that some of these domains are `ClusterBitSet`, that no longer works. So this commit replaces the `Borrow`/`BorrowMut` usage with a new trait `BitSetExt` containing the needed bitset operations. The impls just forward these to the underlying bitset type. This required fiddling with trait bounds in a few places. The commit also: - Moves `static_assert_size` from `rustc_data_structures` to `rustc_index` so it can be used in the latter; the former now re-exports it so existing users are unaffected. - Factors out some common "clear excess bits in the final word" functionality in `bit_set.rs`. - Uses `fill` in a few places instead of loops.
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-4/+1
2022-02-19Adopt let else in more placesest31-25/+16
2022-02-17Remove unused `unsound_ignore_borrow_on_drop`Tomasz Miąsko-34/+11
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-2/+2
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-10Fix switch on discriminant detection in a presence of coverage countersTomasz Miąsko-15/+18
2022-02-03rustc_mir_dataflow: use iter::once instead of Some().into_iterMichael Howell-3/+2
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-17/+0
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-1/+1
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-13/+1
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler
2021-12-16Remove `in_band_lifetimes` from `rustc_mir_dataflow`LegionMammal978-60/+70
See #91867 for more information.
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-05Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obkbors-0/+1
Add a MIR pass manager (Taylor's Version) The final draft of #91386 and #77665. While the compile-time constraints in #91386 are cool, I decided on a more minimal approach for now. I want to explore phase constraints and maybe relative-ordering constraints in the future, though. This should preserve existing behavior **exactly** (please let me know if it doesn't) while making the following changes to the way we organize things today: - Each `MirPhase` now corresponds to a single MIR pass. `run_passes` is not responsible for listing the correct MIR phase. - `run_passes` no longer silently skips passes if the declared MIR phase is greater than or equal to the body's. This has bitten me multiple times. If you want this behavior, you can always branch on `body.phase` yourself. - If your pass is solely to emit errors, you can use the `MirLint` interface instead, which gets a shared reference to `Body` instead of a mutable one. By differentiating the two, I hope to make it clearer in the short term where lints belong in the pipeline. In the long term perhaps we could enforce this at compile-time? - MIR is no longer dumped for passes that aren't enabled, or for lints. I tried to check that `-Zvalidate` still works correctly, since the MIR phase is now updated as soon as the associated pass is done, instead of at the end of all the passes in `run_passes`. However, it looks like `-Zvalidate` is broken with current nightlies anyways :cry: (it spits out a bunch of errors). cc `@oli-obk` `@wesleywiser` r? rust-lang/wg-mir-opt
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-109/+191
2021-12-02Update passes with new interfaceDylan MacKenzie-0/+1
2021-11-23Auto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiserbors-6/+67
Mark places as initialized when mutably borrowed Fixes the example in #90752, but does not handle some corner cases involving raw pointers and unsafe. See [this comment](https://github.com/rust-lang/rust/issues/90752#issuecomment-965822895) for more information, or the second test. Although I talked about both `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` in #90752, this PR only changes the latter. That's because "maybe uninitialized" is the conservative choice, and marking them as definitely initialized (`!maybe_uninitialized`) when a mutable borrow is created could lead to problems if `addr_of_mut` to an uninitialized local is allowed. Additionally, places cannot become uninitialized via a mutable reference, so if a place is definitely initialized, taking a mutable reference to it should not change that. I think it's correct to ignore interior mutability as nbdd0121 suggests below. Their analysis doesn't work inside of `core::cell`, which *does* have access to `UnsafeCell`'s field, but that won't be an issue unless we explicitly instantiate one with an `enum` within that module. r? `@wesleywiser`
2021-11-13Mark mutably borrowed places as maybe initializedDylan MacKenzie-6/+67
2021-11-11Use `associated_item_def_ids` moreMatthew Jasper-7/+2
2021-11-03Remove `MaybeMutBorrowedLocals`Tomasz Miąsko-148/+17
2021-10-23Ignore errors re: unreachable blocks in dataflow cursor unit testsDylan MacKenzie-0/+9
2021-10-23update cfg(bootstrap)Pietro Albini-1/+0
2021-10-20Remove NullOp::BoxGary Guo-13/+1
2021-10-16Adopt let_else across the compilerest31-6/+3
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-07comma-related changesEliza Weisman-1/+1
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07make them structured while i'm hereEliza Weisman-2/+2
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07demote `rustc_peek` traces look not user-facingEliza Weisman-2/+2
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-05Rollup merge of #89532 - ecstatic-morse:maybe-live-locals-enum, ↵Manish Goregaokar-0/+31
r=oli-obk,tmiasko Document behavior of `MaybeLiveLocals` regarding enums and field-senstivity This arose from a [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/MaybeLiveLocals.20and.20Discriminants) where a new contributor attempted to implement a dead-store elimination pass using this analysis. They ran into a nasty hack around `SetDiscriminant` the effect of which is to lets handle assignments of literals to enum-typed locals (e.g. `x = Some(4)`) correctly. This took me a while to figure out. Document this oddity, so the next person will have an easier time, and add a test to enshrine the current behavior. r? ``@tmiasko``
2021-10-04Discuss field-sensitivity and enums in context of `MaybeLiveLocals`Dylan MacKenzie-0/+31
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-1/+1
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Stabilize `const_panic`Jacob Pratt-1/+1
2021-10-03Replace Fn impls with RPIT impls in rustc_indexbjorn3-3/+4
This is cleaner and removes an unstable feature usage
2021-09-28More tracing instrumentationOli Scherer-12/+6