summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder.rs
AgeCommit message (Collapse)AuthorLines
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-19/+23
And suggest adding the `#[coroutine]` to the closure
2024-04-17consistency rename: language item -> lang itemRalf Jung-1/+1
2024-03-20Split item bounds and item super predicatesMichael Goulet-0/+14
2024-03-16less useless array builds in imported_source_fileklensy-10/+10
2024-03-08Move metadata header and version checks togetherbjorn3-6/+18
This will make it easier to report rustc versions for older metadata formats.
2024-03-06Auto merge of #119455 - Mark-Simulacrum:relative-spans, r=cjgillotbors-1/+5
Embed length of offset/position into Span tag byte This cuts the average bytes/relative span from 3.5 to 3.2 on libcore, ultimately saving ~400kb of data.
2024-03-05Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelixbors-1/+1
Add a scheme for moving away from `extern "rust-intrinsic"` entirely All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic. This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic. cc https://github.com/rust-lang/rust/issues/63585 follow-up to #120500 MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-04Return a struct from `query intrinsic` to be able to add another field in ↵Oli Scherer-1/+1
the next commit
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-1/+1
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-2/+2
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-6/+4
2024-02-15Use generic `NonZero` internally.Markus Reiter-6/+8
2024-02-12Implement intrinsics with fallback bodiesOli Scherer-2/+2
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-2/+2
2024-02-12Lower anonymous structs or unions to HIRFrank King-0/+3
2024-02-06resolve: Unload speculatively resolved crates before freezing cstoreVadim Petrochenkov-0/+7
2024-01-17Improved collapse_debuginfo attribute, added command-line flag (no|external|yes)Andrew Zhogin-0/+1
2024-01-06Embed length of offset/position into Span tag byteMark Rousskov-1/+5
This cuts the average bytes/relative span from 3.5 to 3.2 on libcore, ultimately saving ~400kb of data.
2024-01-06Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiserbors-70/+59
Avoid specialization in the metadata serialization code With the exception of a perf-only specialization for byte slices and byte vectors. This uses the same trick of introducing a new trait and having the Encodable and Decodable derives add a bound to it as used for TyEncoder/TyDecoder. The new code is clearer about which encoder/decoder uses which impl and it reduces the dependency of rustc on specialization, making it easier to remove support for specialization entirely or turn it into a construct that is only allowed for perf optimizations if we decide to do this.
2024-01-04cstore: Remove unnecessary locking from `CrateMetadata`Vadim Petrochenkov-20/+19
2023-12-31Avoid specialization for AttrId deserializationbjorn3-6/+3
2023-12-31Remove almost all uses of specialization from the metadata encoding codebjorn3-57/+49
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-9/+9
2023-12-29Shrink span encoding furtherMark Rousskov-21/+19
Spans are now stored in a more compact form which cuts down on at least 1 byte per span (indirect/direct encoding) and at most 3 bytes per span (indirect/direct encoding, context byte, length byte). As a result, libcore metadata shrinks by 1.5MB.
2023-12-27Support relative offsets when encoding spansMark Rousskov-1/+9
The relative offset is often smaller than the absolute offset, and with the LEB128 encoding, this ends up cutting the overall metadata size considerably (~1.5 megabytes on libcore). We can support both relative and absolute encodings essentially for free since we already take a full byte to differentiate between direct and indirect encodings (so an extra variant is quite cheap).
2023-12-24Auto merge of #119139 - michaelwoerister:cleanup-stable-source-file-id, ↵bors-2/+2
r=cjgillot Unify SourceFile::name_hash and StableSourceFileId This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before. The PR should also fix issues https://github.com/rust-lang/rust/issues/112700 and https://github.com/rust-lang/rust/issues/115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
2023-12-24Auto merge of #119265 - Mark-Simulacrum:remove-cache, r=cjgillotbors-22/+8
Remove metadata decoding DefPathHash cache My expectation is that this cache is largely useless. Decoding a DefPathHash from metadata is essentially a pair of memory loads - there's no heavyweight processing involved. Caching it behind a HashMap just adds extra cost and incurs hashing overheads for the indices. Based on https://github.com/rust-lang/rust/pull/119238.
2023-12-24Auto merge of #119238 - Mark-Simulacrum:def-hash-efficiency, r=cjgillotbors-3/+11
Skip duplicate stable crate ID encoding into metadata Instead, we store just the local crate hash as a bare u64. On decoding, we recombine it with the crate's stable crate ID stored separately in metadata. The end result is that we save ~8 bytes/DefIndex in metadata size. One key detail here is that we no longer distinguish in encoded metadata between present and non-present DefPathHashes. It used to be highly likely we could distinguish as we used DefPathHash::default(), an all-zero representation. However in theory even that is fallible as nothing strictly prevents the StableCrateId from being zero. In review it was pointed out that we should never have a missing hash for a DefIndex anyway, so this shouldn't matter.
2023-12-23Remove metadata decoding DefPathHash cacheMark Rousskov-22/+8
This cache is largely useless. Decoding a DefPathHash from metadata is essentially a pair of memory loads - there's no heavyweight processing involved. Caching it behind a HashMap just adds extra cost and incurs hashing overheads.
2023-12-23Specialize DefPathHash table to skip crate IDsMark Rousskov-3/+11
Instead, we store just the local crate hash as a bare u64. On decoding, we recombine it with the crate's stable crate ID stored separately in metadata. The end result is that we save ~8 bytes/DefIndex in metadata size. One key detail here is that we no longer distinguish in encoded metadata between present and non-present DefPathHashes. It used to be highly likely we could distinguish as we used DefPathHash::default(), an all-zero representation. However in theory even that is fallible as nothing strictly prevents the StableCrateId from being zero.
2023-12-23Auto merge of #119225 - Mark-Simulacrum:remove-option, r=compiler-errorsbors-1/+1
Avoid redundant Option for cross_crate_inlinable
2023-12-22Avoid redundant Option for cross_crate_inlinableMark Rousskov-1/+1
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-2/+2
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-2/+2
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-11Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkinbors-14/+11
Use a u64 for the rmeta root position Waffle noticed this in https://github.com/rust-lang/rust/pull/117301#discussion_r1405410174 We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now. r? `@WaffleLapkin`
2023-12-10Apply suggestions from code reviewBen Kimock-2/+1
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-12-10remove redundant importssurechen-19/+9
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-28Use a u64 for the rmeta root positionBen Kimock-13/+11
2023-11-25rustc: Make `def_kind` mandatory for all `DefId`sVadim Petrochenkov-9/+6
2023-11-20Store feature stability un-splitMichael Goulet-12/+8
2023-11-20Unify defined_lib_features and lib_features queriesMichael Goulet-3/+15
2023-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-0/+4
2023-10-13Format all the let chains in compilerMichael Goulet-5/+10
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-19/+0
2023-09-22Merge `ExternProviders` into the general `Providers` structOli Scherer-1/+0
2023-09-12Fix two typosbjorn3-1/+1
2023-09-10Support listing all items in -Zlsbjorn3-10/+80
2023-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-69/+116