File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,17 @@ bool CodeMotionContext::run() {
254254 // Initialize the data flow.
255255 initializeCodeMotionDataFlow ();
256256
257+ if (RCRootVault.size () > 500 ) {
258+ // Emergency exit to avoid bad compile time problems in rare corner cases.
259+ // This limit is more than enough for "real world" code.
260+ // Even large functions have < 100 locations.
261+ // But in some corner cases - especially in generated code - we can run
262+ // into quadratic complexity for large functions.
263+ // TODO: eventually the ARCCodeMotion passes will be replaced by OSSA
264+ // optimizations which shouldn't have this problem.
265+ return false ;
266+ }
267+
257268 // Converge the BBSetOut with iterative data flow.
258269 if (MultiIteration) {
259270 initializeCodeMotionBBMaxSet ();
Original file line number Diff line number Diff line change @@ -1204,6 +1204,17 @@ bool DSEContext::run() {
12041204 //
12051205 // Initialize the BBToLocState mapping.
12061206 unsigned LocationNum = this ->getLocationVault ().size ();
1207+
1208+ if (LocationNum > 500 ) {
1209+ // Emergency exit to avoid bad compile time problems in rare corner cases.
1210+ // This limit is more than enough for "real world" code.
1211+ // Even large functions have < 100 locations.
1212+ // But in some corner cases - especially in generated code - we can run
1213+ // into quadratic complexity for large functions.
1214+ // TODO: implement DSE with a better (non-quadratic) algorithm
1215+ return false ;
1216+ }
1217+
12071218 for (auto bs : BBToLocState) {
12081219 bs.data .init (&bs.block , LocationNum, Optimistic);
12091220 bs.data .initStoreSetAtEndOfBlock (*this );
You can’t perform that action at this time.
0 commit comments