@@ -956,10 +956,25 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
956
956
{
957
957
tcx. ensure_ok( ) . exportable_items( LOCAL_CRATE ) ;
958
958
tcx. ensure_ok( ) . stable_order_of_exportable_impls( LOCAL_CRATE ) ;
959
+
960
+ // Prefetch this as it is used later by the loop below
961
+ // to prevent multiple threads from blocking on it.
962
+ tcx. ensure_done( ) . get_lang_items( ( ) ) ;
963
+
964
+ let _timer = tcx. sess. timer( "misc_module_passes" ) ;
959
965
tcx. par_hir_for_each_module( |module| {
960
966
tcx. ensure_ok( ) . check_mod_loops( module) ;
961
967
tcx. ensure_ok( ) . check_mod_attrs( module) ;
962
968
tcx. ensure_ok( ) . check_mod_naked_functions( module) ;
969
+ } ) ;
970
+ } ,
971
+ {
972
+ // Prefetch this as it is used later by the loop below
973
+ // to prevent multiple threads from blocking on it.
974
+ tcx. ensure_done( ) . stability_index( ( ) ) ;
975
+
976
+ let _timer = tcx. sess. timer( "check_unstable_api_usage" ) ;
977
+ tcx. par_hir_for_each_module( |module| {
963
978
tcx. ensure_ok( ) . check_mod_unstable_api_usage( module) ;
964
979
} ) ;
965
980
} ,
@@ -994,30 +1009,47 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
994
1009
// This improves performance by allowing lock-free access to them.
995
1010
tcx. untracked ( ) . definitions . freeze ( ) ;
996
1011
997
- sess. time ( "MIR_borrow_checking" , || {
998
- tcx. par_hir_body_owners ( |def_id| {
999
- // Run unsafety check because it's responsible for stealing and
1000
- // deallocating THIR.
1001
- tcx. ensure_ok ( ) . check_unsafety ( def_id) ;
1002
- if !tcx. is_typeck_child ( def_id. to_def_id ( ) ) {
1003
- tcx. ensure_ok ( ) . mir_borrowck ( def_id)
1004
- }
1005
- } ) ;
1006
- } ) ;
1007
- sess. time ( "MIR_effect_checking" , || {
1008
- tcx. par_hir_body_owners ( |def_id| {
1009
- tcx. ensure_ok ( ) . has_ffi_unwind_calls ( def_id) ;
1010
-
1011
- // If we need to codegen, ensure that we emit all errors from
1012
- // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
1013
- // them later during codegen.
1014
- if tcx. sess . opts . output_types . should_codegen ( )
1015
- || tcx. hir_body_const_context ( def_id) . is_some ( )
1012
+ sess. time ( "misc_checking_2" , || {
1013
+ parallel ! (
1014
+ {
1015
+ // Prefetch this as it is used later by lint checking and privacy checking.
1016
+ tcx. ensure_done( ) . effective_visibilities( ( ) ) ;
1017
+ } ,
1016
1018
{
1017
- tcx. ensure_ok ( ) . mir_drops_elaborated_and_const_checked ( def_id) ;
1019
+ sess. time( "MIR_borrow_checking" , || {
1020
+ tcx. par_hir_body_owners( |def_id| {
1021
+ // Run unsafety check because it's responsible for stealing and
1022
+ // deallocating THIR.
1023
+ tcx. ensure_ok( ) . check_unsafety( def_id) ;
1024
+ if !tcx. is_typeck_child( def_id. to_def_id( ) ) {
1025
+ tcx. ensure_ok( ) . mir_borrowck( def_id)
1026
+ }
1027
+ } ) ;
1028
+ } ) ;
1029
+ } ,
1030
+ {
1031
+ sess. time( "MIR_effect_checking" , || {
1032
+ tcx. par_hir_body_owners( |def_id| {
1033
+ tcx. ensure_ok( ) . has_ffi_unwind_calls( def_id) ;
1034
+
1035
+ // If we need to codegen, ensure that we emit all errors from
1036
+ // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
1037
+ // them later during codegen.
1038
+ if tcx. sess. opts. output_types. should_codegen( )
1039
+ || tcx. hir_body_const_context( def_id) . is_some( )
1040
+ {
1041
+ tcx. ensure_ok( ) . mir_drops_elaborated_and_const_checked( def_id) ;
1042
+ }
1043
+ } ) ;
1044
+ } ) ;
1045
+ } ,
1046
+ {
1047
+ sess. time( "layout_testing" , || layout_test:: test_layout( tcx) ) ;
1048
+ sess. time( "abi_testing" , || abi_test:: test_abi( tcx) ) ;
1018
1049
}
1019
- } ) ;
1050
+ )
1020
1051
} ) ;
1052
+
1021
1053
sess. time ( "coroutine_obligations" , || {
1022
1054
tcx. par_hir_body_owners ( |def_id| {
1023
1055
if tcx. is_coroutine ( def_id. to_def_id ( ) ) {
@@ -1036,9 +1068,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
1036
1068
} ) ;
1037
1069
} ) ;
1038
1070
1039
- sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
1040
- sess. time ( "abi_testing" , || abi_test:: test_abi ( tcx) ) ;
1041
-
1042
1071
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
1043
1072
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
1044
1073
// in MIR optimizations that may only be reachable through codegen, or other codepaths
@@ -1074,26 +1103,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
1074
1103
sess. time ( "misc_checking_3" , || {
1075
1104
parallel ! (
1076
1105
{
1077
- tcx. ensure_ok( ) . effective_visibilities( ( ) ) ;
1078
-
1079
- parallel!(
1080
- {
1081
- tcx. ensure_ok( ) . check_private_in_public( ( ) ) ;
1082
- } ,
1083
- {
1084
- tcx. par_hir_for_each_module( |module| {
1085
- tcx. ensure_ok( ) . check_mod_deathness( module)
1086
- } ) ;
1087
- } ,
1088
- {
1089
- sess. time( "lint_checking" , || {
1090
- rustc_lint:: check_crate( tcx) ;
1091
- } ) ;
1092
- } ,
1093
- {
1094
- tcx. ensure_ok( ) . clashing_extern_declarations( ( ) ) ;
1095
- }
1096
- ) ;
1106
+ tcx. ensure_ok( ) . check_private_in_public( ( ) ) ;
1107
+ } ,
1108
+ {
1109
+ tcx. par_hir_for_each_module( |module| tcx. ensure_ok( ) . check_mod_deathness( module) ) ;
1110
+ } ,
1111
+ {
1112
+ sess. time( "lint_checking" , || {
1113
+ rustc_lint:: check_crate( tcx) ;
1114
+ } ) ;
1115
+ } ,
1116
+ {
1117
+ tcx. ensure_ok( ) . clashing_extern_declarations( ( ) ) ;
1097
1118
} ,
1098
1119
{
1099
1120
sess. time( "privacy_checking_modules" , || {
0 commit comments