@@ -1054,25 +1054,39 @@ static void checkAccessedAddress(Operand *memOper, StorageMap &Accesses) {
10541054
10551055namespace {
10561056
1057- class DiagnoseStaticExclusivity : public SILFunctionTransform {
1057+ // / TODO: This is currently a module transform to ensure that source-level
1058+ // / diagnostics, like DiagnoseInvalidCaptures run on closures (in addition to
1059+ // / other callees) before this pass processes their parent functions. Otherwise,
1060+ // / AccessSummaryAnalysis may crash on invalid SIL. Fix the pass manager to
1061+ // / ensure that closures are always diagnosed before their parent. Then add an
1062+ // / SCC transform to ensure that the previous diagnostic pass runs on all
1063+ // / functions in the SCC before the next diagnostic pass. This will handle
1064+ // / closures that call back into their parent. Then this can be converted to an
1065+ // / SCC transform.
1066+ class DiagnoseStaticExclusivity : public SILModuleTransform {
10581067public:
10591068 DiagnoseStaticExclusivity () {}
10601069
10611070private:
10621071 void run () override {
1063- // Don't rerun diagnostics on deserialized functions.
1064- if (getFunction ()-> wasDeserializedCanonical ())
1065- return ;
1072+ for ( auto &function : * getModule ()) {
1073+ if (!function. isDefinition ())
1074+ continue ;
10661075
1067- SILFunction *Fn = getFunction ();
1068- // This is a staging flag. Eventually the ability to turn off static
1069- // enforcement will be removed.
1070- if (!Fn->getModule ().getOptions ().EnforceExclusivityStatic )
1071- return ;
1076+ // Don't rerun diagnostics on deserialized functions.
1077+ if (function.wasDeserializedCanonical ())
1078+ continue ;
10721079
1073- PostOrderFunctionInfo *PO = getAnalysis<PostOrderAnalysis>()->get (Fn);
1074- auto *ASA = getAnalysis<AccessSummaryAnalysis>();
1075- checkStaticExclusivity (*Fn, PO, ASA);
1080+ // This is a staging flag. Eventually the ability to turn off static
1081+ // enforcement will be removed.
1082+ if (!function.getModule ().getOptions ().EnforceExclusivityStatic )
1083+ continue ;
1084+
1085+ PostOrderFunctionInfo *PO =
1086+ getAnalysis<PostOrderAnalysis>()->get (&function);
1087+ auto *ASA = getAnalysis<AccessSummaryAnalysis>();
1088+ checkStaticExclusivity (function, PO, ASA);
1089+ }
10761090 }
10771091};
10781092
0 commit comments