summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/query
AgeCommit message (Collapse)AuthorLines
2021-01-25Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiserbors-0/+11
Prevent query cycles in the MIR inliner r? `@eddyb` `@wesleywiser` cc `@rust-lang/wg-mir-opt` The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR. The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles. This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
2021-01-23Prevent query cycles during inliningoli-0/+11
2021-01-23Iterate to encode def_kind.Camille GILLOT-0/+16
2021-01-17Impl EncodableWithShorthand for PredicateKindJack Huey-0/+5
2021-01-16Can't use EncodableWithShorthand for PredicateJack Huey-5/+0
2021-01-13Properly handle `SyntaxContext` of dummy spans in incr compAaron Hill-12/+20
Fixes #80336 Due to macro expansion, we may end up with spans with an invalid location and non-root `SyntaxContext`. This commits preserves the `SyntaxContext` of such spans in the incremental cache, and ensures that we always hash the `SyntaxContext` when computing the `Fingerprint` of a `Span` Previously, we would discard the `SyntaxContext` during serialization to the incremental cache, causing the span's `Fingerprint` to change across compilation sessions.
2021-01-11Serialize incr comp structures to file via fixed-size bufferTyson Nottingham-36/+52
Reduce a large memory spike that happens during serialization by writing the incr comp structures to file by way of a fixed-size buffer, rather than an unbounded vector. Effort was made to keep the instruction count close to that of the previous implementation. However, buffered writing to a file inherently has more overhead than writing to a vector, because each write may result in a handleable error. To reduce this overhead, arrangements are made so that each LEB128-encoded integer can be written to the buffer with only one capacity and error check. Higher-level optimizations in which entire composite structures can be written with one capacity and error check are possible, but would require much more work. The performance is mostly on par with the previous implementation, with small to moderate instruction count regressions. The memory reduction is significant, however, so it seems like a worth-while trade-off.
2021-01-08Make force_from_dep_node a function pointer.Camille GILLOT-107/+1
2021-01-08Make try_load_from_on_disk_cache a function pointer.Camille GILLOT-26/+0
2021-01-04Auto merge of #80610 - Aaron1011:unhash-def-path-hash, r=varkorbors-8/+9
Use `UnhashMap` whenever we have a key of `DefPathHash`
2021-01-01rustc_serialize: specialize opaque decoding of some u8 sequencesTyson Nottingham-0/+9
2021-01-01rustc_serialize: specialize opaque encoding of some u8 sequencesTyson Nottingham-0/+10
2021-01-01Use `UnhashMap` whenever we have a key of `DefPathHash`Aaron Hill-8/+9
2020-12-23Rollup merge of #80204 - pierwill:pierwill-rustcmiddle-ondisk, r=varkorGuillaume Gomez-2/+2
docs: Edit rustc_middle::ty::query::on_disk_cache Expand abbreviations for "incremental compliation". Also added the word "to" to the description of CacheEncoder.
2020-12-19docs: Edit rustc_middle::ty::query::on_disk_cachepierwill-2/+2
Expand abbreviations for "incremental compliation". Also added the word "to" to the description of CacheEncoder.
2020-12-18OnDiskCache: avoid storing local def id hashes in foreign def id collectionTyson Nottingham-2/+4
2020-12-18rustc_query_system: explicitly register reused dep nodesTyson Nottingham-9/+25
Register nodes that we've reused from the previous session explicitly with `OnDiskCache`. Previously, we relied on this happening as a side effect of accessing the nodes in the `PreviousDepGraph`. For the sake of performance and avoiding unintended side effects, register explictily.
2020-12-14Remove unused `TyEncoder::tcx` required methodLeSeulArtichaut-3/+0
2020-12-10Use `def_path_hash_to_def_id` when re-using a `RawDefId`Aaron Hill-3/+21
Fixes #79890 Previously, we just copied a `RawDefId` from the 'old' map to the 'new' map. However, the `RawDefId` for a given `DefPathHash` may be different in the current compilation session. Using `def_path_hash_to_def_id` ensures that the `RawDefId` we use is valid in the current session.
2020-12-04Properly re-use def path hash in incremental modeAaron Hill-1/+1
Fixes #79661 In incremental compilation mode, we update a `DefPathHash -> DefId` mapping every time we create a `DepNode` for a foreign `DefId`. This mapping is written out to the on-disk incremental cache, and is read by the next compilation session to allow us to lazily decode `DefId`s. When we decode a `DepNode` from the current incremental cache, we need to ensure that any previously-recorded `DefPathHash -> DefId` mapping gets recorded in the new mapping that we write out. However, PR #74967 didn't do this in all cases, leading to us being unable to decode a `DefPathHash` in certain circumstances. This PR refactors some of the code around `DepNode` deserialization to prevent this kind of mistake from happening again.
2020-12-03Auto merge of #79637 - spastorino:revert-trait-inheritance-self, ↵bors-23/+1
r=Mark-Simulacrum Revert "Auto merge of #79209 r? `@nikomatsakis` This has caused some issues (#79560) so better to revert and try to come up with a proper fix without rush.
2020-12-02Revert "Auto merge of #79209 - spastorino:trait-inheritance-self, ↵Santiago Pastorino-23/+1
r=nikomatsakis" This reverts commit 349b3b324dade7ca638091db93ba08bbc443c63d, reversing changes made to b776d1c3e3db8befabb123ebb1e46c3531eaed46.
2020-12-01Auto merge of #74967 - Aaron1011:feature/incr-def-path-table, r=pnkfelixbors-7/+172
Implement lazy decoding of DefPathTable during incremental compilation PR https://github.com/rust-lang/rust/pull/75813 implemented lazy decoding of the `DefPathTable` from crate metadata. However, it requires decoding the entire `DefPathTable` when incremental compilation is active, so that we can map a decoded `DefPathHash` to a `DefId` from an arbitrary crate. This PR adds support for lazy decoding of dependency `DefPathTable`s when incremental compilation si active. When we load the incremental cache and dep graph, we need the ability to map a `DefPathHash` to a `DefId` in the current compilation session (if the corresponding definition still exists). This is accomplished by storing the old `DefId` (that is, the `DefId` from the previous compilation session) for each `DefPathHash` we need to remap. Since a `DefPathHash` includes the owning crate, the old crate is guaranteed to be the right one (if the definition still exists). We then use the old `DefIndex` as an initial guess, which we validate by comparing the expected and actual `DefPathHash`es. In most cases, foreign crates will be completely unchanged, which means that we our guess will be correct. If our guess is wrong, we fall back to decoding the entire `DefPathTable` for the foreign crate. This still represents an improvement over the status quo, since we can skip decoding the entire `DefPathTable` for other crates (where all of our guesses were correct).
2020-11-27Allow to self reference associated types in where clausesSantiago Pastorino-0/+11
2020-11-27Allow to use super trait bounds in where clausesSantiago Pastorino-1/+12
2020-11-25Fix rebase falloutAaron Hill-1/+7
2020-11-25Only populate local_def_path_hash_to_def_id when neededAaron Hill-3/+6
2020-11-25Lazy DefPath decoding for incremental compilationAaron Hill-8/+164
2020-11-25Fix typosDániel Buga-2/+2
2020-11-19Only create `OnDiskCache` in incremental compilation modeAaron Hill-3/+4
This lets us skip doing useless work when we're not in incremental compilation mode.
2020-11-14Move Steal to rustc_data_structures.Camille GILLOT-1/+1
2020-10-22Retire rustc_dep_node_try_load_from_on_disk_cache.Camille GILLOT-1/+23
2020-10-22Retire rustc_dep_node_force.Camille GILLOT-13/+36
2020-10-22Unify query name and node name.Camille GILLOT-3/+3
2020-10-22Remove unused category from macros.Camille GILLOT-16/+6
2020-10-22Remove unused ProfileCategory.Camille GILLOT-3/+0
2020-10-22Auto merge of #77871 - Julian-Wollersberger:less-query-context, r=oli-obkbors-18/+21
Make fewer types generic over QueryContext While trying to refactor `rustc_query_system::query::QueryContext` to make it dyn-safe, I noticed some smaller things: * QueryConfig doesn't need to be generic over QueryContext * ~~The `kind` field on QueryJobId is unused~~ * Some unnecessary where clauses * Many types in `job.rs` where generic over `QueryContext` but only needed `QueryContext::Query`. If handle_cycle_error() could be refactored to not take `error: CycleError<CTX::Query>`, all those bounds could be removed as well. Changing `find_cycle_in_stack()` in job.rs to not take a `tcx` argument is the only functional change here. Everything else is just updating type signatures. (aka compile-error driven development ^^) ~~Currently there is a weird bug where memory usage suddenly skyrockets when running UI tests. I'll investigate that tomorrow. A perf run probably won't make sense before that is fixed.~~ EDIT: `kind` actually is used by `Eq`, and re-adding it fixed the memory issue.
2020-10-19Remove <CTX: QueryContext> in a bunch of places.Julian Wollersberger-15/+18
It was only needed by `find_cycle_in_stack()` in job.rs, but needed to be forwarded through dozens of types.
2020-10-16Rollup merge of #77493 - ↵Dylan DPC-3/+10
hosseind88:ICEs_should_always_print_the_top_of_the_query_stack, r=oli-obk ICEs should always print the top of the query stack see #76920
2020-10-14Remove unused code from rustc_middleest31-23/+0
2020-10-13Replace absolute paths with relative onesest31-2/+2
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-12Remove generic argument from `QueryConfig`.Julian Wollersberger-3/+3
2020-10-09change condition for end of query stack messagehosseind88-4/+4
2020-10-09fix show we're just showing... message instead of the end of query stack ↵hosseind75-3/+0
message when RUST_BACKTRACE=0
2020-10-09show a message when we are showing limited slice of query stackhosseind75-0/+3
2020-10-09change approach and run ui testshosseind75-5/+1
2020-10-09run full query stack print just when RUST_BACKTRACE is sethosseind75-1/+5
2020-10-09ICEs should print the top of the query stackhosseind75-13/+1
2020-10-09rebase with masterhosseind75-0/+8
2020-10-09fix show we're just showing... message instead of the end of query stack ↵hosseind75-1/+5
message when RUST_BACKTRACE=0