summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src
AgeCommit message (Collapse)AuthorLines
2023-05-26Add struct for the return type of `place_root_mono_items`.Nicholas Nethercote-6/+13
As per review request.
2023-05-25Remove some unnecessary `pub` markers.Nicholas Nethercote-2/+2
2023-05-24Add a clarifying comment.Nicholas Nethercote-0/+2
This is something that took me some time to figure out.
2023-05-24Remove `{Pre,Post}InliningPartitioning`.Nicholas Nethercote-87/+64
I find that these structs obfuscate the code. Removing them and just passing the individual fields around makes the `Partition` method signatures a little longer, but makes the data flow much clearer. E.g. - `codegen_units` is mutable all the way through. - `codegen_units`'s length is changed by `merge_codegen_units`, but only the individual elements are changed by `place_inlined_mono_items` and `internalize_symbols`. - `roots`, `internalization_candidates`, and `mono_item_placements` are all immutable after creation, and all used by just one of the four methods.
2023-05-24Remove the `merging` module.Nicholas Nethercote-109/+94
Three of the four methods in `DefaultPartitioning` are defined in `default.rs`. But `merge_codegen_units` is defined in a separate module, `merging`, even though it's less than 100 lines of code and roughly the same size as the other three methods. (Also, the `merging` module currently sits alongside `default`, when it should be a submodule of `default`, adding to the confusion.) In #74275 this explanation was given: > I pulled this out into a separate module since it seemed like we might > want a few different merge algorithms to choose from. But in the three years since there have been no additional merging algorithms, and there is no mechanism for choosing between different merging algorithms. (There is a mechanism, `-Zcgu-partitioning-strategy`, for choosing between different partitioning strategies, but the merging algorithm is just one piece of a partitioning strategy.) This commit merges `merging` into `default`, making the code easier to navigate and read.
2023-05-24Inline and remove `numbered_codegen_unit_name`.Nicholas Nethercote-8/+3
It is small and has a single call site, and this change will facilitate the next commit.
2023-05-19Improve CGU partitioning debug output.Nicholas Nethercote-10/+16
- Pass a slice instead of an iterator to `debug_dump`. - For each CGU set, print: the number of CGUs, the max and min size, and the ratio of the max and min size (which indicates how evenly sized they are). - Print a `FINAL` entry, showing the absolute final results.
2023-05-19Fix an ICE in CGU dumping code.Nicholas Nethercote-2/+2
2023-05-17Finish move of query.rsJohn Kåre Alsaker-3/+2
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-3/+4
2023-05-06use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda-1/+1
2023-05-06make (try_)subst_and_normalize_erasing_regions take EarlyBinderKyle Matsuda-3/+3
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-2/+6
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-01Box AssertKindBen Kimock-1/+1
2023-04-27rename `needs_subst` to `has_param`Boxy-1/+1
2023-04-26Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle-1/+2
a `Span`
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-2/+5
2023-04-23Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillotbors-1/+1
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-22Auto merge of #110567 - JohnBobbo96:monomorphize-dyn-dispatch, r=b-naberbors-20/+91
Remove some uses of dynamic dispatch during monomorphization/partitioning. This removes a few uses of dynamic dispatch and instead uses generics, as well as an enum to allow for other partitioning methods to be added later.
2023-04-21Allow `LocalDefId` as the argument to `def_path_str`Oli Scherer-1/+1
2023-04-20Remove WithOptconstParam.Camille GILLOT-8/+7
2023-04-19Remove a few uses of dynamic dispatch duringJohn Bobbo-20/+91
monomorphization/partitioning with the use of an enum.
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-1/+1
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+1
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-17Spelling - compilerJosh Soref-2/+2
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-15fix clippy::{filter_map_identiy, map_identity, manual_flatten}Matthias Krüger-1/+1
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-1/+1
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
2023-04-06Add `UnwindAction::Terminate`Gary Guo-0/+10
2023-04-02Rollup merge of #109846 - matthiaskrgr:clippy2023_04_III, r=NilstriebNilstrieb-4/+1
more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool)
2023-04-01fix clippy::iter_kv_mapMatthias Krüger-4/+1
2023-04-01a couple clippy::complexity fixesMatthias Krüger-2/+2
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-31Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors-1/+2
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Rollup merge of #109758 - nnethercote:parallel-cleanups, r=cjgillotMichael Goulet-5/+5
Parallel compiler cleanups A few small improvements I found while looking closely at this code. r? `@cjgillot` cc `@Zoxc,` `@SparrowLii`
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+2
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Improve the `rustc_data_structures::sync` module doc comment.Nicholas Nethercote-5/+5
Also, `MTRef<'a, T>` is a typedef for a reference to a `T`, but in practice it's only used (and useful) in combination with `MTLock`, i.e. `MTRef<'a, MTLock<T>>`. So this commit changes it to be a typedef for a reference to an `MTLock<T>`, and renames it as `MTLockRef`. I think this clarifies things, because I found `MTRef` quite puzzling at first.
2023-03-29Support TLS access into dylibs on WindowsJohn Kåre Alsaker-20/+39
2023-03-28Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstriebbors-19/+29
Rollup of 8 pull requests Successful merges: - #91793 (socket ancillary data implementation for FreeBSD (from 13 and above).) - #92284 (Change advance(_back)_by to return the remainder instead of the number of processed elements) - #102472 (stop special-casing `'static` in evaluation) - #108480 (Use Rayon's TLV directly) - #109321 (Erase impl regions when checking for impossible to eagerly monomorphize items) - #109470 (Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`) - #109562 (Update ar_archive_writer to 0.1.3) - #109629 (remove obsolete `givens` from regionck) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-28Erase impl regions when checking for impossible to eagerly monomorphize itemsMichael Goulet-19/+29
2023-03-27Add a builtin `FnPtr` traitlcnr-3/+6
2023-03-15Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=NilstriebDylan DPC-7/+2
Use `unused_generic_params` from crate metadata Due to the way that `separate_provide_extern` interacted with the implementation of `<ty::InstanceDef<'tcx> as Key>::query_crate_is_local`, we actually never hit the foreign provider for `unused_generic_params`. Additionally, since the *local* provider of `unused_generic_params` calls `should_polymorphize`, which always returns false if the def-id is foreign, this means that we never actually polymorphize monomorphic instances originating from foreign crates. We don't actually encode `unused_generic_params` for items where all generics are used, so I had to tweak the foreign provider to fall back to `ty::UnusedGenericParams::new_all_used()` to avoid more ICEs when the above bugs were fixed.
2023-03-14Use `unused_generic_params` from crate metadataMichael Goulet-7/+2
2023-03-14Don't codegen impossible to satisfy implsMichael Goulet-0/+15
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-09Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgrbors-2/+1
Rollup of 8 pull requests Successful merges: - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous) - #108759 (1.41.1 supported 32-bit Apple targets) - #108839 (Canonicalize root var when making response from new solver) - #108856 (Remove DropAndReplace terminator) - #108882 (Tweak E0740) - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap) - #108911 (Improve rustdoc-gui/tester.js code a bit) - #108916 (Remove an unused return value in `rustc_hir_typeck`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-2/+1
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Simplify `sort_by` callsMaybe Waffle-2/+2
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-2/+1
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-24Rename many interner functions.Nicholas Nethercote-1/+1
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup