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