about summary refs log tree commit diff
path: root/compiler/rustc_index/src
AgeCommit message (Collapse)AuthorLines
2022-07-21Edit `rustc_index::vec::IndexVec::pick3_mut` docspierwill-2/+6
Clarify when this method will panic. Also fix formatting for `pick2_mut`.
2022-07-08Fix cloning from a BitSet with a different domain sizeTomasz Miąsko-6/+19
The previous implementation incorrectly assumed that the number of words in a bit set is equal to the domain size. The new implementation delegates to `Vec::clone_from` which is specialized for `Copy` elements.
2022-07-04Use a bitset instead of a hash map in HIR ID validatorJakub Beránek-0/+10
2022-06-21Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obkbors-0/+12
Remove dereferencing of Box from codegen Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains. Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-17Auto merge of #97863 - JakobDegen:bitset-choice, r=nnethercotebors-18/+135
`BitSet` related perf improvements This commit makes two changes: 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet` 2. Overrides the `fold` method for the iterator for `ChunkedBitSet` I have local benchmarks verifying that each of these changes individually yield significant perf improvements to #96451 . I'm hoping this will be true outside of that context too. If that is not the case, I'll try to gate things on where they help as needed r? `@nnethercote` who I believe was working on closely related things, cc `@tmiasko` because of the destprop pr
2022-06-15add From impls for BitSet and GrowableBitSetDrMeepster-0/+12
2022-06-14`BitSet` perf improvementsJakob Degen-18/+135
This commit makes two changes: 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet` 2. Overrides the `fold` method for the iterator for `ChunkedBitSet`
2022-06-09Auto merge of #97862 - SparrowLii:superset, r=lcnrbors-13/+58
optimize `superset` method of `IntervalSet` Given that intervals in the `IntervalSet` are sorted and strictly separated( it means the `end` of the previous interval will not be equal to the `start` of the next interval), we can reduce the complexity of the `superset` method from O(NMlogN) to O(2N) (N is the number of intervals and M is the length of each interval)
2022-06-08correct the test if IntervalSetSparrowLii-1/+1
2022-06-08fix the impl error in `insert_all`SparrowLii-1/+3
2022-06-08add `check_invariants` methodSparrowLii-7/+33
2022-06-08optimize `superset` method of `IntervalSet`SparrowLii-4/+21
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-2/+2
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-05-20Auto merge of #95418 - cjgillot:more-disk, r=davidtwcobors-6/+0
Cache more queries on disk One of the principles of incremental compilation is to allow saving results on disk to avoid recomputing them. This PR investigates persisting a lot of queries whose result are to be saved into metadata. Some of the queries are cheap reads from HIR, but we may also want to get rid of these reads for incremental lowering.
2022-05-13Cache more queries on disk.Camille GILLOT-6/+0
2022-05-10optimize `insert_range` method of `IntervalSet`SparrowLii-48/+45
2022-04-30Add element iterator for ChunkedBitSetTomasz Miąsko-0/+82
2022-04-27tut tut tutEllen-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
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-15Fix small typo in FIXMEMartin Gammelsæter-2/+2
2022-03-07Add comment linking to closed PR for future optimizersMartin Gammelsæter-4/+8
While optimizing these operations proved unfruitful w.r.t. improving compiler performance right now, faster versions might be needed at a later time.
2022-02-24Fix testAaron Hill-1/+5
2022-02-24Convert `newtype_index` to a proc macroAaron Hill-455/+2
The `macro_rules!` implementation was becomng excessively complicated, and difficult to modify. The new proc macro implementation should make it much easier to add new features (e.g. skipping certain `#[derive]`s)
2022-02-23Introduce `ChunkedBitSet` and use it for some dataflow analyses.Nicholas Nethercote-28/+677
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-19Adopt let else in more placesest31-12/+6
2022-02-16Adopt let_else in even more placesest31-5/+1
2022-02-01implement lint for suspicious auto trait implslcnr-0/+6
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-4/+4
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-12remove unused FIXMElcnr-4/+0
2021-12-30Introduce IntervalSetMark Rousskov-0/+469
This is a compact, fast storage for variable-sized sets, typically consisting of larger ranges. It is less efficient than a bitset if ranges are both small and the domain size is small, but will still perform acceptably. With enormous domain sizes and large ranges, the interval set performs much better, as it can be much more densely packed in memory than the uncompressed bit set alternative.
2021-12-22Require Ord for rustc_index::SparseBitSet::last_set_inpierwill-3/+8
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-2/+2
Implement `Ord`, `PartialOrd` for SpanData
2021-12-18Derive hash for BitSet and BitMatrixTomasz Miąsko-2/+2
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-11-24Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasperbors-1/+238
Optimize live point computation This refactors the live-point computation to lower per-MIR-instruction costs by operating on a largely per-block level. This doesn't fundamentally change the number of operations necessary, but it greatly improves the practical performance by aggregating bit manipulation into ranges rather than single-bit; this scales much better with larger blocks. On the benchmark provided in #90445, with 100,000 array elements, walltime for a check build is improved from 143 seconds to 15. I consider the tiny losses here acceptable given the many small wins on real world benchmarks and large wins on stress tests. The new code scales much better, but on some subset of inputs the slightly higher constant overheads decrease performance somewhat. Overall though, this is expected to be a big win for pathological cases (as illustrated by the test case motivating this work) and largely not material for non-pathological cases. I consider the new code somewhat easier to follow, too.
2021-11-13Generate documentation in rustc `rustc_index::newtype_index` macropierwill-1/+23
The macro now documents all generated items. Documentation notes possible panics and unsafety.
2021-11-03Optimize live point computationMark Rousskov-1/+238
This is just replicating the previous algorithm, but taking advantage of the bitset structures to optimize into tighter and better optimized loops. Particularly advantageous on enormous MIR blocks, which are relatively rare in practice.
2021-10-23update cfg(bootstrap)Pietro Albini-6/+0
2021-10-15Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, ↵Matthias Krüger-7/+11
r=petrochenkov" The PR had some unforseen perf regressions that are not as easy to find. Revert the PR for now. This reverts commit 6ae8912a3e7d2c4c775024f58a7ba4b1aedc4073, reversing changes made to 86d6d2b7389fe1b339402c1798edae8b695fc9ef.
2021-10-12Use Option::map_or instead of open coding itLingMan-1/+1
2021-10-11Rollup merge of #89643 - cjgillot:overlap, r=matthewjasperMatthias Krüger-0/+6
Fix inherent impl overlap check. The current implementation of the overlap check was slightly buggy, and unified the wrong connected component in the `ids.len() <= 1` case. This became visible in another PR which changed the iteration order of items. r? ``@matthewjasper`` since you reviewed the other PR.
2021-10-11Remove unnecessary variableClemens Wasser-2/+1
2021-10-10Apply clippy suggestionsClemens Wasser-10/+7
2021-10-07Fix inherent impl overlap check.Camille GILLOT-0/+6
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-2/+6
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-2/+6
2021-10-03Replace Fn impls with RPIT impls in rustc_indexbjorn3-45/+17
This is cleaner and removes an unstable feature usage
2021-10-02Swap out unboxed_closures feature gate for min_specializationbjorn3-1/+1
For some reason unboxed_closures supresses the feature gate for min_specialization when implementing TrustedStep. min_specialization is the true feature that is used.
2021-09-22rustc_index: Add some map-like APIs to `IndexVec`Vadim Petrochenkov-6/+17
2021-08-27Suggested changesWill Crichton-2/+2