summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/encoder.rs
AgeCommit message (Collapse)AuthorLines
2021-02-04Encode less consts.Camille GILLOT-7/+16
2021-02-03Address review.Camille GILLOT-6/+2
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-59/+27
2021-01-23Iterate DefId to encode spans.Camille GILLOT-13/+15
2021-01-23Encode DefKind directly.Camille GILLOT-87/+134
2021-01-17Impl EncodableWithShorthand for PredicateKindJack Huey-0/+6
2021-01-16Can't use EncodableWithShorthand for PredicateJack Huey-6/+0
2021-01-14Encode optimized MIR of generators when emitting metadataTomasz Miąsko-1/+4
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-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-33/+87
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-04Keep an unoptimized duplicate of `const fn` aroundoli-18/+69
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-03Auto merge of #80247 - tmiasko:indent, r=bjorn3bors-1/+1
Fix indentation of -Z meta-stats output
2021-01-01adjust const generics defaults FIXMEs to the new feature gateRémy Rakic-1/+1
2020-12-20Fix indentation of -Z meta-stats outputTomasz Miąsko-1/+1
2020-12-17Rollup merge of #80039 - LeSeulArtichaut:rm-tyencoder-tcx, r=matthewjasperYuki Okushi-4/+0
Remove unused `TyEncoder::tcx` required method Unsure if this is helpful or not... r? ``@ghost`` cc ``@matthewjasper`` ``@jackh726``
2020-12-14Convenience funcs for `some_option.unwrap_or(...)`Rich Kadel-6/+1
This ensures consistent handling of default values for options that are None if not specified on the command line.
2020-12-14Remove unused `TyEncoder::tcx` required methodLeSeulArtichaut-4/+0
2020-12-14Improve warnings on incompatible options involving -Zinstrument-coverageRich Kadel-1/+6
Adds checks for: * `no_core` attribute * explicitly-enabled `legacy` symbol mangling * mir_opt_level > 1 (which enables inlining) I removed code from the `Inline` MIR pass that forcibly disabled inlining if `-Zinstrument-coverage` was set. The default `mir_opt_level` does not enable inlining anyway. But if the level is explicitly set and is greater than 1, I issue a warning. The new warnings show up in tests, which is much better for diagnosing potential option conflicts in these cases.
2020-11-27Encode proc_macro directly.Camille GILLOT-5/+35
Encode proc_macro name directly. Do not store None values.
2020-11-26Formatting.Camille GILLOT-1/+1
2020-11-26Remove ForeignMod struct.Camille GILLOT-4/+4
2020-11-26Store ForeignItem in a side table.Camille GILLOT-1/+8
2020-11-03Auto merge of #78448 - rylev:cache-foreign_modules, r=wesleywiserbors-1/+1
foreign_modules query hash table lookups When compiling a large monolithic crate we're seeing huge times in the `foreign_modules` query due to repeated iteration over foreign modules (in order to find a module by its id). This implements hash table lookups so that which massively reduces time spent in that query in this particular case. We'll need to see if the overhead of creating the hash table has a negative impact on performance in more normal compilation scenarios. I'm working with `@wesleywiser` on this.
2020-10-29Avoid BorrowMutError with RUSTC_LOG=debugTomasz Miąsko-3/+6
$ touch empty.rs $ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs Fails with a `BorrowMutError` because source map files are already borrowed while `features_query` attempts to format a log message containing a span. Release the borrow before the query to avoid the issue.
2020-10-27Cache foreign_modules queryRyan Levick-1/+1
2020-10-19Calculate visibilities once in resolveVadim Petrochenkov-56/+13
Then use them through a query based on resolver outputs
2020-10-06Separate bounds and predicates for associated/opaque typesMatthew Jasper-1/+4
2020-10-06Split bounds from predicatesMatthew Jasper-1/+12