Commit c6df438
committed
Add a safeguard to SimplifyCFG tryJumpThreading to avoid infinite loop peeling
rdar://73644659 (Add a safeguard to SimplifyCFG tryJumpThreading to avoid infinite loop peeling)
A case of infinite loop peeling was exposed recently:
([SR-14068]: Compiling with optimisation runs indefinitely for grpc-swift)
It was trivially fixed here:
---
commit 8948f75 (HEAD -> fix-simplifycfg-tramp, public/fix-simplifycfg-tramp)
Author: Andrew Trick <atrick@apple.com>
Date: Tue Jan 26 17:02:37 2021
Fix a SimplifyCFG typo that leads to unbounded optimization
---
However, that fix isn't a strong guarantee against this behavior. The
obvious complete fix is that jump-threading should not affect loop
structure. But changing that requires a performance investigation. In
the meantime this change introduces a simple mechanism that guarantees
that a loop header is not repeatedly cloned.
This safeguard is worthwhile because jump-threading across loop
boundaries is kicking in more frequently now the critical edges are
being split within SimplifyCFG.
Note that it is both necessary and desirable to split critical edges
between transformations so that SIL remains in a valid state. That
allows other code in SimplifyCFG to call arbitrary SIL utilities,
allows verifying SimplifyCFG by running verification between
transformation, and simplifies the patters that SimplifyCFG itself
needs to consider.
(cherry picked from commit 8b20984)1 parent e3e2849 commit c6df438
1 file changed
+33
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
| |||
170 | 184 | | |
171 | 185 | | |
172 | 186 | | |
173 | | - | |
| 187 | + | |
174 | 188 | | |
| 189 | + | |
| 190 | + | |
175 | 191 | | |
176 | 192 | | |
177 | 193 | | |
| |||
1082 | 1098 | | |
1083 | 1099 | | |
1084 | 1100 | | |
1085 | | - | |
| 1101 | + | |
1086 | 1102 | | |
1087 | 1103 | | |
1088 | | - | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1089 | 1108 | | |
1090 | 1109 | | |
1091 | 1110 | | |
| |||
1127 | 1146 | | |
1128 | 1147 | | |
1129 | 1148 | | |
1130 | | - | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
1131 | 1155 | | |
| 1156 | + | |
1132 | 1157 | | |
1133 | 1158 | | |
1134 | 1159 | | |
| |||
1375 | 1400 | | |
1376 | 1401 | | |
1377 | 1402 | | |
1378 | | - | |
1379 | | - | |
| 1403 | + | |
1380 | 1404 | | |
1381 | 1405 | | |
1382 | 1406 | | |
| |||
1400 | 1424 | | |
1401 | 1425 | | |
1402 | 1426 | | |
1403 | | - | |
1404 | | - | |
| 1427 | + | |
1405 | 1428 | | |
1406 | 1429 | | |
1407 | 1430 | | |
| |||
1586 | 1609 | | |
1587 | 1610 | | |
1588 | 1611 | | |
1589 | | - | |
1590 | | - | |
| 1612 | + | |
1591 | 1613 | | |
1592 | 1614 | | |
1593 | 1615 | | |
| |||
1605 | 1627 | | |
1606 | 1628 | | |
1607 | 1629 | | |
1608 | | - | |
1609 | | - | |
| 1630 | + | |
1610 | 1631 | | |
1611 | 1632 | | |
1612 | 1633 | | |
| |||
0 commit comments