File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -226,10 +226,20 @@ void MandatoryGenericSpecializer::run() {
226226 continue ;
227227
228228 // Perform generic specialization and other related optimzations.
229- bool changed = optimize (func, cha);
230229
231- if (changed)
232- invalidateAnalysis (func, SILAnalysis::InvalidationKind::Everything);
230+ // To avoid phase ordering problems of the involved optimizations, iterate
231+ // until we reach a fixed point.
232+ // This should always happen, but to be on the save side, limit the number
233+ // of iterations to 10 (which is more than enough - usually the loop runs
234+ // 1 to 3 times).
235+ for (int i = 0 ; i < 10 ; i++) {
236+ bool changed = optimize (func, cha);
237+ if (changed) {
238+ invalidateAnalysis (func, SILAnalysis::InvalidationKind::Everything);
239+ } else {
240+ break ;
241+ }
242+ }
233243
234244 // Continue specializing called functions.
235245 for (SILBasicBlock &block : *func) {
You can’t perform that action at this time.
0 commit comments