2021-01-02 14:42:15 +01:00
|
|
|
#![feature(array_windows)]
|
Improve CGU debug printing.
- Add more total and per-CGU measurements.
- Ensure CGUs are sorted by name before the first `debug_dump` calls,
for deterministic output.
- Print items within CGUs in sorted-by-name order, for deterministic
output.
- Add some assertions and comments clarifying sortedness of CGUs at
various points.
An example, before:
```
INITIAL PARTITIONING (5 CodegenUnits, max=29, min=1, max/min=29.0):
CodegenUnit scev95ysd7g4b0z estimated size 2:
- fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] estimated size 2
CodegenUnit 1j0frgtl72rsz24q estimated size 29:
- fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] estimated size 17
- fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] estimated size 12
CodegenUnit 5dbzi1e5qm0d7kj2 estimated size 4:
- fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] estimated size 1
- fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] estimated size 1
- fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] estimated size 1
- fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] estimated size 1
CodegenUnit 220m1mqa2mlbg7r3 estimated size 1:
- fn main [(External, Hidden)] [hb29587cdb6db5f42E] estimated size 1
CodegenUnit 4ulbh241f7tvyn7x estimated size 6:
- fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] estimated size 6
```
and after:
```
INITIAL PARTITIONING (9 items, total_size=42; 5 CGUs, max_size=29, min_size=1, max_size/min_size=29.0):
- CGU[0] 1j0frgtl72rsz24q (2 items, size=29):
- fn std::rt::lang_start::<()> [(External, Hidden)] [h4ca942948e9cb931E] (size=12)
- fn std::rt::lang_start::<()>::{closure#0} [(External, Hidden)] [h695c7b5d6a212565E] (size=17)
- CGU[1] 220m1mqa2mlbg7r3 (1 items, size=1):
- fn main [(External, Hidden)] [hb29587cdb6db5f42E] (size=1)
- CGU[2] 4ulbh241f7tvyn7x (1 items, size=6):
- fn std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> [(External, Hidden)] [h41dada2c21a1259dE] (size=6)
- CGU[3] 5dbzi1e5qm0d7kj2 (4 items, size=4):
- fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim(vtable) [(External, Hidden)] [h595d414cbb7651d5E] (size=1)
- fn <[closure@std::rt::lang_start<()>::{closure#0}] as std::ops::FnOnce<()>>::call_once - shim [(External, Hidden)] [h24eaa44f03b2b233E] (size=1)
- fn <fn() as std::ops::FnOnce<()>>::call_once - shim(fn()) [(External, Hidden)] [hf338f5339c3711acE] (size=1)
- fn std::ptr::drop_in_place::<[closure@std::rt::lang_start<()>::{closure#0}]> - shim(None) [(External, Hidden)] [h17a19dcdb40600daE] (size=1)
- CGU[4] scev95ysd7g4b0z (1 items, size=2):
- fn <() as std::process::Termination>::report [(External, Hidden)] [h082b15a6d07338dcE] (size=2)
```
2023-06-01 10:03:27 +10:00
|
|
|
#![feature(is_sorted)]
|
2021-09-01 21:05:35 +02:00
|
|
|
#![recursion_limit = "256"]
|
2022-02-23 08:06:22 -05:00
|
|
|
#![allow(rustc::potential_query_instability)]
|
2022-08-18 15:51:47 -06:00
|
|
|
#![deny(rustc::untranslatable_diagnostic)]
|
|
|
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
2021-01-02 14:42:15 +01:00
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate tracing;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rustc_middle;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
2023-04-16 14:33:00 +02:00
|
|
|
use rustc_fluent_macro::fluent_messages;
|
2021-01-02 14:42:15 +01:00
|
|
|
use rustc_hir::lang_items::LangItem;
|
2023-05-16 01:53:21 +02:00
|
|
|
use rustc_middle::query::{Providers, TyCtxtAt};
|
2020-03-29 16:41:09 +02:00
|
|
|
use rustc_middle::traits;
|
|
|
|
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
|
2022-11-17 14:39:19 +00:00
|
|
|
use rustc_middle::ty::{self, Ty};
|
2017-10-25 16:14:51 +02:00
|
|
|
|
2021-01-02 14:42:15 +01:00
|
|
|
mod collector;
|
2022-08-18 15:51:47 -06:00
|
|
|
mod errors;
|
2021-01-02 14:42:15 +01:00
|
|
|
mod partitioning;
|
|
|
|
mod polymorphize;
|
|
|
|
mod util;
|
2017-10-25 16:14:51 +02:00
|
|
|
|
2023-03-03 00:18:38 +01:00
|
|
|
fluent_messages! { "../messages.ftl" }
|
2022-10-13 10:13:02 +01:00
|
|
|
|
2021-01-07 00:41:55 -05:00
|
|
|
fn custom_coerce_unsize_info<'tcx>(
|
2022-11-17 14:39:19 +00:00
|
|
|
tcx: TyCtxtAt<'tcx>,
|
2019-06-12 00:11:55 +03:00
|
|
|
source_ty: Ty<'tcx>,
|
|
|
|
target_ty: Ty<'tcx>,
|
|
|
|
) -> CustomCoerceUnsized {
|
2023-04-25 16:07:48 +00:00
|
|
|
let trait_ref = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
2023-04-26 10:55:11 +00:00
|
|
|
tcx.tcx,
|
2023-04-25 16:07:48 +00:00
|
|
|
LangItem::CoerceUnsized,
|
2023-04-26 10:55:11 +00:00
|
|
|
tcx.span,
|
2023-04-25 16:07:48 +00:00
|
|
|
[source_ty, target_ty],
|
|
|
|
));
|
2017-10-25 16:14:51 +02:00
|
|
|
|
2022-09-09 13:36:27 +02:00
|
|
|
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
|
2020-09-24 19:22:36 +02:00
|
|
|
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
|
2020-06-02 15:54:24 +00:00
|
|
|
impl_def_id,
|
|
|
|
..
|
|
|
|
})) => tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap(),
|
2020-05-11 15:25:33 +00:00
|
|
|
impl_source => {
|
|
|
|
bug!("invalid `CoerceUnsized` impl_source: {:?}", impl_source);
|
2017-10-25 16:14:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-02 14:42:15 +01:00
|
|
|
|
|
|
|
pub fn provide(providers: &mut Providers) {
|
|
|
|
partitioning::provide(providers);
|
|
|
|
polymorphize::provide(providers);
|
|
|
|
}
|