summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow
AgeCommit message (Collapse)AuthorLines
2023-06-03unique borrows are mutating useslcnr-2/+1
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-3/+9
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-17/+17
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-3/+9
2023-05-17Rollup merge of #110930 - b-naber:normalize-elaborate-drops, r=cjgillotDylan DPC-0/+1
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-10Auto merge of #110820 - cjgillot:faster-dcp, r=oli-obkbors-124/+166
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-10don't inline polymorphic adt instances whose fields contain projectionsb-naber-8/+3
in DropGlue.
2023-05-09Explicitly skip arguments.Camille GILLOT-0/+1
2023-05-09Implement SSA-based reference propagation.Camille GILLOT-1/+67
2023-05-09Prevent stack overflow.Camille GILLOT-1/+2
2023-05-09Add a few comments.Camille GILLOT-6/+12
2023-05-09Do not flood on copy_nonoverlapping.Camille GILLOT-5/+7
2023-05-09Extract handle_set_discriminant.Camille GILLOT-2/+20
2023-05-09Trim the places that will not be used.Camille GILLOT-1/+10
2023-05-09Precompute values to flood.Camille GILLOT-19/+51
2023-05-09Create tracked places breadth first.Camille GILLOT-65/+49
2023-05-09Make HasTop and HasBottom consts.Camille GILLOT-32/+22
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-0/+1
2023-04-28dont expect normalization to succeed in elaborate_dropsb-naber-3/+9
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-11/+11
2023-04-21offset_ofDrMeepster-1/+1
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-1/+2
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+2
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-10Fix typos in compilerDaniPopes-8/+8
2023-04-06Revert box_free unwind actionGary Guo-1/+5
2023-04-06Fix new usage of old apiGary Guo-1/+1
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-5/+5
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
2023-04-06Add `UnwindAction::Terminate`Gary Guo-2/+2
2023-04-06Add `UnwindAction::Unreachable`Gary Guo-1/+1
This also makes eval machine's `StackPopUnwind` redundant so that is replaced.
2023-04-06Refactor unwind from Option to a new enumGary Guo-19/+19
2023-04-05Rollup merge of #109847 - clubby789:graphviz-reachable, r=oli-obkYuki Okushi-2/+10
Only create graphviz nodes for reachable MIR bb's Fixes #109832
2023-04-05Disable path trimming during graphviz outputclubby789-1/+2
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-9/+9
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-02Auto merge of #109008 - clubby789:drop-elaborate-array, r=davidtwcobors-18/+54
Drop array patterns using subslices Fixes #109004 Drops contiguous subslices of an array when moving elements out with a pattern, which improves perf for large arrays r? `@compiler-errors`
2023-04-01Only create graphviz nodes for reachable MIR bb'sclubby789-2/+10
2023-03-31Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors-3/+3
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-3/+3
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-sebors-1/+0
Partial stabilization of `once_cell` This PR aims to stabilize a portion of the `once_cell` feature: - `core::cell::OnceCell` - `std::cell::OnceCell` (re-export of the above) - `std::sync::OnceLock` This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag. Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue) Future steps for separate PRs: - ~~Add `#[inline]` to many methods~~ #105651 - Update cranelift usage of the `once_cell` crate - Update rust-analyzer usage of the `once_cell` crate - Update error messages discussing once_cell ## To be stabilized API summary ```rust // core::cell (in core/cell/once.rs) pub struct OnceCell<T> { .. } impl<T> OnceCell<T> { pub const fn new() -> OnceCell<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceCell<T>; impl<T: Debug> Debug for OnceCell<T> impl<T> Default for OnceCell<T>; impl<T> From<T> for OnceCell<T>; impl<T: PartialEq> PartialEq for OnceCell<T>; impl<T: Eq> Eq for OnceCell<T>; ``` ```rust // std::sync (in std/sync/once_lock.rs) impl<T> OnceLock<T> { pub const fn new() -> OnceLock<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceLock<T>; impl<T: Debug> Debug for OnceLock<T>; impl<T> Default for OnceLock<T>; impl<#[may_dangle] T> Drop for OnceLock<T>; impl<T> From<T> for OnceLock<T>; impl<T: PartialEq> PartialEq for OnceLock<T> impl<T: Eq> Eq for OnceLock<T>; impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>; unsafe impl<T: Send> Send for OnceLock<T>; unsafe impl<T: Sync + Send> Sync for OnceLock<T>; impl<T: UnwindSafe> UnwindSafe for OnceLock<T>; ``` No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate: ```rust impl<T> OnceCell<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } impl<T> OnceLock<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } ``` I am new to this process so would appreciate mentorship wherever needed.
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+0
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-12/+12
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-3/+3
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-17Drop subslices of arraysclubby789-18/+54
2023-03-14Use index based drop loop for slices and arraysTomasz Miąsko-101/+32
Instead of building two kinds of drop pair loops, of which only one will be eventually used at runtime in a given monomorphization, always use index based loop.
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+4
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-11/+2
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-11/+2
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-05Erase lifetimes in SROA.Camille GILLOT-4/+5
2023-02-25Auto merge of #108250 - nnethercote:rename-interner-funcs, r=compiler-errorsbors-3/+3
Rename interner funcs This PR cleans up some inconsistencies in interner naming. Best reviewed one commit at a time. r? `@compiler-errors`