@@ -913,10 +913,24 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
913
913
CStore :: from_tcx( tcx) . report_unused_deps( tcx) ;
914
914
} ,
915
915
{
916
+ // Prefetch this as it is used later by the loop below
917
+ // to prevent multiple threads from blocking on it.
918
+ tcx. ensure_done( ) . get_lang_items( ( ) ) ;
919
+
920
+ let _timer = tcx. sess. timer( "misc_module_passes" ) ;
916
921
tcx. par_hir_for_each_module( |module| {
917
922
tcx. ensure_ok( ) . check_mod_loops( module) ;
918
923
tcx. ensure_ok( ) . check_mod_attrs( module) ;
919
924
tcx. ensure_ok( ) . check_mod_naked_functions( module) ;
925
+ } ) ;
926
+ } ,
927
+ {
928
+ // Prefetch this as it is used later by the loop below
929
+ // to prevent multiple threads from blocking on it.
930
+ tcx. ensure_done( ) . stability_index( ( ) ) ;
931
+
932
+ let _timer = tcx. sess. timer( "check_unstable_api_usage" ) ;
933
+ tcx. par_hir_for_each_module( |module| {
920
934
tcx. ensure_ok( ) . check_mod_unstable_api_usage( module) ;
921
935
} ) ;
922
936
} ,
@@ -951,30 +965,47 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
951
965
// This improves performance by allowing lock-free access to them.
952
966
tcx. untracked ( ) . definitions . freeze ( ) ;
953
967
954
- sess. time ( "MIR_borrow_checking" , || {
955
- tcx. par_hir_body_owners ( |def_id| {
956
- // Run unsafety check because it's responsible for stealing and
957
- // deallocating THIR.
958
- tcx. ensure_ok ( ) . check_unsafety ( def_id) ;
959
- if !tcx. is_typeck_child ( def_id. to_def_id ( ) ) {
960
- tcx. ensure_ok ( ) . mir_borrowck ( def_id)
961
- }
962
- } ) ;
963
- } ) ;
964
- sess. time ( "MIR_effect_checking" , || {
965
- tcx. par_hir_body_owners ( |def_id| {
966
- tcx. ensure_ok ( ) . has_ffi_unwind_calls ( def_id) ;
967
-
968
- // If we need to codegen, ensure that we emit all errors from
969
- // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
970
- // them later during codegen.
971
- if tcx. sess . opts . output_types . should_codegen ( )
972
- || tcx. hir_body_const_context ( def_id) . is_some ( )
968
+ sess. time ( "misc_checking_2" , || {
969
+ parallel ! (
970
+ {
971
+ // Prefetch this as it is used later by lint checking and privacy checking.
972
+ tcx. ensure_done( ) . effective_visibilities( ( ) ) ;
973
+ } ,
974
+ {
975
+ sess. time( "MIR_borrow_checking" , || {
976
+ tcx. par_hir_body_owners( |def_id| {
977
+ // Run unsafety check because it's responsible for stealing and
978
+ // deallocating THIR.
979
+ tcx. ensure_ok( ) . check_unsafety( def_id) ;
980
+ if !tcx. is_typeck_child( def_id. to_def_id( ) ) {
981
+ tcx. ensure_ok( ) . mir_borrowck( def_id)
982
+ }
983
+ } ) ;
984
+ } ) ;
985
+ } ,
986
+ {
987
+ sess. time( "MIR_effect_checking" , || {
988
+ tcx. par_hir_body_owners( |def_id| {
989
+ tcx. ensure_ok( ) . has_ffi_unwind_calls( def_id) ;
990
+
991
+ // If we need to codegen, ensure that we emit all errors from
992
+ // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
993
+ // them later during codegen.
994
+ if tcx. sess. opts. output_types. should_codegen( )
995
+ || tcx. hir_body_const_context( def_id) . is_some( )
996
+ {
997
+ tcx. ensure_ok( ) . mir_drops_elaborated_and_const_checked( def_id) ;
998
+ }
999
+ } ) ;
1000
+ } ) ;
1001
+ } ,
973
1002
{
974
- tcx. ensure_ok ( ) . mir_drops_elaborated_and_const_checked ( def_id) ;
1003
+ sess. time( "layout_testing" , || layout_test:: test_layout( tcx) ) ;
1004
+ sess. time( "abi_testing" , || abi_test:: test_abi( tcx) ) ;
975
1005
}
976
- } ) ;
1006
+ )
977
1007
} ) ;
1008
+
978
1009
sess. time ( "coroutine_obligations" , || {
979
1010
tcx. par_hir_body_owners ( |def_id| {
980
1011
if tcx. is_coroutine ( def_id. to_def_id ( ) ) {
@@ -991,9 +1022,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
991
1022
} ) ;
992
1023
} ) ;
993
1024
994
- sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
995
- sess. time ( "abi_testing" , || abi_test:: test_abi ( tcx) ) ;
996
-
997
1025
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
998
1026
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
999
1027
// in MIR optimizations that may only be reachable through codegen, or other codepaths
@@ -1029,26 +1057,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
1029
1057
sess. time ( "misc_checking_3" , || {
1030
1058
parallel ! (
1031
1059
{
1032
- tcx. ensure_ok( ) . effective_visibilities( ( ) ) ;
1033
-
1034
- parallel!(
1035
- {
1036
- tcx. ensure_ok( ) . check_private_in_public( ( ) ) ;
1037
- } ,
1038
- {
1039
- tcx. par_hir_for_each_module( |module| {
1040
- tcx. ensure_ok( ) . check_mod_deathness( module)
1041
- } ) ;
1042
- } ,
1043
- {
1044
- sess. time( "lint_checking" , || {
1045
- rustc_lint:: check_crate( tcx) ;
1046
- } ) ;
1047
- } ,
1048
- {
1049
- tcx. ensure_ok( ) . clashing_extern_declarations( ( ) ) ;
1050
- }
1051
- ) ;
1060
+ tcx. ensure_ok( ) . check_private_in_public( ( ) ) ;
1061
+ } ,
1062
+ {
1063
+ tcx. par_hir_for_each_module( |module| tcx. ensure_ok( ) . check_mod_deathness( module) ) ;
1064
+ } ,
1065
+ {
1066
+ sess. time( "lint_checking" , || {
1067
+ rustc_lint:: check_crate( tcx) ;
1068
+ } ) ;
1069
+ } ,
1070
+ {
1071
+ tcx. ensure_ok( ) . clashing_extern_declarations( ( ) ) ;
1052
1072
} ,
1053
1073
{
1054
1074
sess. time( "privacy_checking_modules" , || {
0 commit comments