@@ -26,7 +26,6 @@ use rustc_parse::{
26
26
} ;
27
27
use rustc_passes:: { abi_test, input_stats, layout_test} ;
28
28
use rustc_resolve:: Resolver ;
29
- use rustc_session:: code_stats:: VTableSizeInfo ;
30
29
use rustc_session:: config:: { CrateType , Input , OutFileName , OutputFilenames , OutputType } ;
31
30
use rustc_session:: cstore:: Untracked ;
32
31
use rustc_session:: output:: { collect_crate_types, filename_for_input, find_crate_name} ;
@@ -985,90 +984,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
985
984
// we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
986
985
let _ = tcx. all_diagnostic_items ( ( ) ) ;
987
986
} ) ;
988
-
989
- if sess. opts . unstable_opts . print_vtable_sizes {
990
- let traits = tcx. traits ( LOCAL_CRATE ) ;
991
-
992
- for & tr in traits {
993
- if !tcx. is_dyn_compatible ( tr) {
994
- continue ;
995
- }
996
-
997
- let name = ty:: print:: with_no_trimmed_paths!( tcx. def_path_str( tr) ) ;
998
-
999
- let mut first_dsa = true ;
1000
-
1001
- // Number of vtable entries, if we didn't have upcasting
1002
- let mut entries_ignoring_upcasting = 0 ;
1003
- // Number of vtable entries needed solely for upcasting
1004
- let mut entries_for_upcasting = 0 ;
1005
-
1006
- let trait_ref = ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, tr) ) ;
1007
-
1008
- // A slightly edited version of the code in
1009
- // `rustc_trait_selection::traits::vtable::vtable_entries`, that works without self
1010
- // type and just counts number of entries.
1011
- //
1012
- // Note that this is technically wrong, for traits which have associated types in
1013
- // supertraits:
1014
- //
1015
- // trait A: AsRef<Self::T> + AsRef<()> { type T; }
1016
- //
1017
- // Without self type we can't normalize `Self::T`, so we can't know if `AsRef<Self::T>`
1018
- // and `AsRef<()>` are the same trait, thus we assume that those are different, and
1019
- // potentially over-estimate how many vtable entries there are.
1020
- //
1021
- // Similarly this is wrong for traits that have methods with possibly-impossible bounds.
1022
- // For example:
1023
- //
1024
- // trait B<T> { fn f(&self) where T: Copy; }
1025
- //
1026
- // Here `dyn B<u8>` will have 4 entries, while `dyn B<String>` will only have 3.
1027
- // However, since we don't know `T`, we can't know if `T: Copy` holds or not,
1028
- // thus we lean on the bigger side and say it has 4 entries.
1029
- traits:: vtable:: prepare_vtable_segments ( tcx, trait_ref, |segment| {
1030
- match segment {
1031
- traits:: vtable:: VtblSegment :: MetadataDSA => {
1032
- // If this is the first dsa, it would be included either way,
1033
- // otherwise it's needed for upcasting
1034
- if std:: mem:: take ( & mut first_dsa) {
1035
- entries_ignoring_upcasting += 3 ;
1036
- } else {
1037
- entries_for_upcasting += 3 ;
1038
- }
1039
- }
1040
-
1041
- traits:: vtable:: VtblSegment :: TraitOwnEntries { trait_ref, emit_vptr } => {
1042
- // Lookup the shape of vtable for the trait.
1043
- let own_existential_entries =
1044
- tcx. own_existential_vtable_entries ( trait_ref. def_id ( ) ) ;
1045
-
1046
- // The original code here ignores the method if its predicates are
1047
- // impossible. We can't really do that as, for example, all not trivial
1048
- // bounds on generic parameters are impossible (since we don't know the
1049
- // parameters...), see the comment above.
1050
- entries_ignoring_upcasting += own_existential_entries. len ( ) ;
1051
-
1052
- if emit_vptr {
1053
- entries_for_upcasting += 1 ;
1054
- }
1055
- }
1056
- }
1057
-
1058
- std:: ops:: ControlFlow :: Continue :: < std:: convert:: Infallible > ( ( ) )
1059
- } ) ;
1060
-
1061
- sess. code_stats . record_vtable_size ( tr, & name, VTableSizeInfo {
1062
- trait_name : name. clone ( ) ,
1063
- entries : entries_ignoring_upcasting + entries_for_upcasting,
1064
- entries_ignoring_upcasting,
1065
- entries_for_upcasting,
1066
- upcasting_cost_percent : entries_for_upcasting as f64
1067
- / entries_ignoring_upcasting as f64
1068
- * 100. ,
1069
- } )
1070
- }
1071
- }
1072
987
}
1073
988
1074
989
/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
@@ -1149,12 +1064,6 @@ pub(crate) fn start_codegen<'tcx>(
1149
1064
tcx. sess . code_stats . print_type_sizes ( ) ;
1150
1065
}
1151
1066
1152
- if tcx. sess . opts . unstable_opts . print_vtable_sizes {
1153
- let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
1154
-
1155
- tcx. sess . code_stats . print_vtable_sizes ( crate_name) ;
1156
- }
1157
-
1158
1067
codegen
1159
1068
}
1160
1069
0 commit comments