about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2021-02-08Rollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiserMara Bos-1/+6
Show MIR bytes separately in -Zmeta-stats output The size of serialized MIR is substantial enough to deserve its own category.
2021-02-07Add `--extern-loc` to augment unused crate dependency diagnosticsJeremy Fitzhardinge-4/+23
This allows a build system to indicate a location in its own dependency specification files (eg Cargo's `Cargo.toml`) which can be reported along side any unused crate dependency. This supports several types of location: - 'json' - provide some json-structured data, which is included in the json diagnostics in a `tool_metadata` field - 'raw' - emit the provided string into the output. This also appears as a json string in `tool_metadata`. If no `--extern-location` is explicitly provided then a default json entry of the form `"tool_metadata":{"name":<cratename>,"path":<cratepath>}` is emitted.
2021-02-07Show MIR bytes separately in -Zmeta-stats outputTomasz Miąsko-1/+6
2021-02-05Auto merge of #81215 - cjgillot:defkey-mir, r=oli-obkbors-215/+103
Encode MIR metadata by iterating on DefId instead of traversing the HIR tree Split out of https://github.com/rust-lang/rust/pull/80347. This part only traverses `mir_keys` and encodes MIR according to the def kind. r? `@oli-obk`
2021-02-04Encode less consts.Camille GILLOT-7/+16
2021-02-03Address review.Camille GILLOT-6/+2
2021-02-02Let a portion of DefPathHash uniquely identify the DefPath's crate.Michael Woerister-3/+43
This allows to directly map from a DefPathHash to the crate it originates from, without constructing side tables to do that mapping. It also allows to reliably and cheaply check for DefPathHash collisions.
2021-01-29Pre-canoncalize ExternLocation::ExactPathsRyan Levick-13/+21
2021-01-26Check for rmeta crates when getting existing crates from cacheRyan Levick-2/+3
2021-01-24Sort mir_keys to ensure consistent diagnostic order.Camille GILLOT-5/+18
2021-01-24Review comment.Camille GILLOT-0/+5
2021-01-24Refactor MIR metadata emission.Camille GILLOT-215/+43
2021-01-24Introduce should_encode_mir.Camille GILLOT-0/+37
2021-01-23Fix proc macro crate encoding.Camille GILLOT-2/+9
2021-01-23Filter stability.Camille GILLOT-3/+40
2021-01-23Iterate on deprecation.Camille GILLOT-10/+1
2021-01-23Iterate on const_stability.Camille GILLOT-4/+1
2021-01-23Iterate on stability.Camille GILLOT-14/+2
2021-01-23Iterate DefId to encode expn_that_defined.Camille GILLOT-4/+1
2021-01-23Iterate DefId to encode attributes.Camille GILLOT-17/+4
2021-01-23Iterate DefId to encode visibility.Camille GILLOT-10/+38
2021-01-23Iterate to encode def_kind.Camille GILLOT-60/+28
2021-01-23Iterate DefId to encode spans.Camille GILLOT-13/+15
2021-01-23Encode DefKind directly.Camille GILLOT-142/+160
2021-01-17Impl EncodableWithShorthand for PredicateKindJack Huey-0/+6
2021-01-16Can't use EncodableWithShorthand for PredicateJack Huey-6/+0
2021-01-15Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, ↵bors-38/+9
r=michaelwoerister Remove DepKind::CrateMetadata and pre-allocation of DepNodes Remove much of the special-case handling around crate metadata dependency tracking by replacing `DepKind::CrateMetadata` and the pre-allocation of corresponding `DepNodes` with on-demand invocation of the `crate_hash` query.
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-2/+2
2021-01-14Encode optimized MIR of generators when emitting metadataTomasz Miąsko-1/+4
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-5/+12
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13Auto merge of #80718 - tmiasko:skip-opt-mir, r=oli-obkbors-32/+39
Consistently avoid constructing optimized MIR when not doing codegen The optimized MIR for closures is being encoded unconditionally, while being unnecessary for cargo check. This turns out to be especially costly with MIR inlining enabled, since it triggers computation of optimized MIR for all callees that are being examined for inlining purposes https://github.com/rust-lang/rust/pull/77307#issuecomment-751915450. Skip encoding of optimized MIR for closures, enum constructors, struct constructors, and trait fns when not doing codegen, like it is already done for other items since 49433.
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-1/+1
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-1/+1
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-13Skip promoted mir of struct constructors & enum constructorsTomasz Miąsko-2/+0
2021-01-13Consistently avoid constructing optimized MIR when not doing codegenTomasz Miąsko-16/+30
The optimized MIR for closures is being encoded unconditionally, while being unnecessary for cargo check. This turns out to be especially costly with MIR inlining enabled, since it triggers computation of optimized MIR for all callees that are being examined for inlining purposes. Skip encoding of optimized MIR for closures, enum constructors, struct constructors, and trait fns when not doing codegen, like it is already done for other items since 49433.
2021-01-12Reorder MIR encoding checksTomasz Miąsko-25/+20
Start from least expensive checks when deciding whether to encode MIR or not. No functional changes intended.
2021-01-12Prevent potential bug resulting from changing crate_hash query nameTyson Nottingham-1/+2
2021-01-12Return to defining crate_hash similarly to other query providersTyson Nottingham-17/+5
2021-01-12Remove DepKind::CrateMetadata and pre-allocation of DepNodesTyson Nottingham-38/+20
Remove much of the special-case handling around crate metadata dependency tracking by replacing `DepKind::CrateMetadata` and the pre-allocation of corresponding `DepNodes` with on-demand invocation of the `crate_hash` query.
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-33/+105
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-11Serialize incr comp structures to file via fixed-size bufferTyson Nottingham-1/+1
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-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-5/+12
2021-01-05Rollup merge of #80643 - LingMan:unwrap, r=oli-obkYuki Okushi-8/+7
Move variable into the only branch where it is relevant At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`. We can branch on the parameter, move the binding into the `if`, and the complexity of handling `Option<Option<_>` largely dissolves. `@rustbot` modify labels +C-cleanup +T-compiler Note: I have no idea how hot this code is. If this method frequently gets called with a `None` filter, there might be a small perf improvement.
2021-01-04Differentiate between the availability of ctfe MIR and runtime MIRoli-1/+5
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-18/+83
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2021-01-04Require the `encode_promoted_mir` caller to know whether MIR for this item ↵oli-3/+1
actually exists
2021-01-04Limit trait item mir encoding to items with default bodiesoli-2/+9
2021-01-04Remove mir encode calls that didn't actually encode anythingoli-2/+0
2021-01-04Make `encode_optimized_mir` always perform its action and instead require ↵oli-11/+11
the callers to know whether they actually want this
2021-01-04Auto merge of #80610 - Aaron1011:unhash-def-path-hash, r=varkorbors-2/+3
Use `UnhashMap` whenever we have a key of `DefPathHash`