Commit 7b55cbc
committed
[sil-optimizer] Make InstructionDeleter and related APIs to use an InstModCallback instead of a notification callback.
I recently have been running into the issue that many of these APIs perform the
deletion operation themselves and notify the caller it is going to delete
instead of allowing the caller to specify how the instruction is deleted. This
causes interesting semantic issues (see the loop in deleteInstruction I
simplified) and breaks composition since many parts of the optimizer use
InstModCallbacks for this purpose.
To fix this, I added a notify will be deleted construct to InstModCallback. In a
similar way to the rest of it, if the notify is not set, we do not call any code
implying that we should have good predictable performance in loops since we will
always skip the function call.
I also changed InstModCallback::deleteInst() to notify before deleting so we
have a default safe behavior. All previous use sites of this API do not care
about being notified and the only new use sites of this API are in
InstructionDeleter that perform special notification behavior (it notifies for
certain sets of instructions it is going to delete before it deletes any of
them). To work around this, I added a bool to deleteInst to control this
behavior and defaulted to notifying. This should ensure that all other use sites
still compose correctly.1 parent c15dde4 commit 7b55cbc
File tree
8 files changed
+425
-382
lines changed- include/swift/SILOptimizer/Utils
- lib/SILOptimizer
- Mandatory
- Utils
- test/SILOptimizer
8 files changed
+425
-382
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
46 | 83 | | |
47 | 84 | | |
48 | 85 | | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
1108 | 1110 | | |
1109 | 1111 | | |
1110 | 1112 | | |
1111 | | - | |
1112 | | - | |
1113 | 1113 | | |
1114 | 1114 | | |
1115 | 1115 | | |
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
1187 | | - | |
1188 | | - | |
| 1187 | + | |
1189 | 1188 | | |
1190 | 1189 | | |
1191 | 1190 | | |
| |||
1194 | 1193 | | |
1195 | 1194 | | |
1196 | 1195 | | |
1197 | | - | |
| 1196 | + | |
1198 | 1197 | | |
1199 | 1198 | | |
1200 | 1199 | | |
1201 | | - | |
| 1200 | + | |
1202 | 1201 | | |
1203 | 1202 | | |
1204 | | - | |
| 1203 | + | |
1205 | 1204 | | |
1206 | | - | |
| 1205 | + | |
1207 | 1206 | | |
1208 | 1207 | | |
1209 | 1208 | | |
1210 | 1209 | | |
1211 | | - | |
1212 | | - | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1213 | 1213 | | |
1214 | 1214 | | |
1215 | 1215 | | |
1216 | 1216 | | |
1217 | | - | |
| 1217 | + | |
1218 | 1218 | | |
1219 | 1219 | | |
1220 | | - | |
| 1220 | + | |
1221 | 1221 | | |
1222 | 1222 | | |
1223 | 1223 | | |
| |||
1226 | 1226 | | |
1227 | 1227 | | |
1228 | 1228 | | |
1229 | | - | |
1230 | 1229 | | |
1231 | 1230 | | |
1232 | 1231 | | |
1233 | 1232 | | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1234 | 1249 | | |
1235 | 1250 | | |
1236 | 1251 | | |
1237 | 1252 | | |
1238 | 1253 | | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
| 1254 | + | |
1252 | 1255 | | |
1253 | 1256 | | |
| 1257 | + | |
1254 | 1258 | | |
1255 | 1259 | | |
1256 | 1260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 77 | + | |
| 78 | + | |
102 | 79 | | |
103 | 80 | | |
104 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1727 | 1727 | | |
1728 | 1728 | | |
1729 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
1730 | 1737 | | |
1731 | 1738 | | |
1732 | 1739 | | |
| |||
1736 | 1743 | | |
1737 | 1744 | | |
1738 | 1745 | | |
1739 | | - | |
1740 | | - | |
1741 | 1746 | | |
1742 | 1747 | | |
1743 | 1748 | | |
| |||
1751 | 1756 | | |
1752 | 1757 | | |
1753 | 1758 | | |
1754 | | - | |
1755 | | - | |
1756 | | - | |
| 1759 | + | |
1757 | 1760 | | |
1758 | 1761 | | |
1759 | 1762 | | |
1760 | 1763 | | |
1761 | 1764 | | |
1762 | 1765 | | |
1763 | 1766 | | |
1764 | | - | |
| 1767 | + | |
| 1768 | + | |
1765 | 1769 | | |
1766 | 1770 | | |
1767 | 1771 | | |
1768 | 1772 | | |
| 1773 | + | |
1769 | 1774 | | |
1770 | 1775 | | |
1771 | 1776 | | |
1772 | 1777 | | |
1773 | 1778 | | |
1774 | 1779 | | |
1775 | | - | |
1776 | | - | |
| 1780 | + | |
1777 | 1781 | | |
1778 | 1782 | | |
1779 | 1783 | | |
| |||
1822 | 1826 | | |
1823 | 1827 | | |
1824 | 1828 | | |
1825 | | - | |
1826 | | - | |
1827 | | - | |
| 1829 | + | |
1828 | 1830 | | |
1829 | 1831 | | |
1830 | 1832 | | |
| |||
1839 | 1841 | | |
1840 | 1842 | | |
1841 | 1843 | | |
1842 | | - | |
1843 | | - | |
1844 | | - | |
1845 | | - | |
| 1844 | + | |
| 1845 | + | |
1846 | 1846 | | |
1847 | 1847 | | |
1848 | 1848 | | |
| |||
1851 | 1851 | | |
1852 | 1852 | | |
1853 | 1853 | | |
1854 | | - | |
1855 | | - | |
1856 | | - | |
1857 | | - | |
| 1854 | + | |
| 1855 | + | |
1858 | 1856 | | |
1859 | 1857 | | |
1860 | 1858 | | |
| |||
1875 | 1873 | | |
1876 | 1874 | | |
1877 | 1875 | | |
1878 | | - | |
| 1876 | + | |
1879 | 1877 | | |
1880 | 1878 | | |
1881 | 1879 | | |
| |||
2022 | 2020 | | |
2023 | 2021 | | |
2024 | 2022 | | |
| 2023 | + | |
2025 | 2024 | | |
2026 | 2025 | | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
| 2026 | + | |
2031 | 2027 | | |
2032 | 2028 | | |
2033 | 2029 | | |
| |||
0 commit comments