Commit e8a2bb4
committed
[RegAlloc] Account for non-rematerializable uses when applying weight discount
This aims to fix the issue that caused https://reviews.llvm.org/D106408 to be reverted.
CalcSpillWeights will reduce the weight of an interval by half if it's considered rematerializable, so it will be evicted before others.
It does this by checking TII.isTriviallyReMaterializable. However rematerialization may still fail if any of the defining MI's uses aren't available at the locations it needs to be rematerialized. LiveRangeEdit::canRematerializeAt calls allUsesAvailableAt to check this.
This fixes it by also checking allUsesAvailableAt in CalcSpillWeights. There may be a better place to share the function than LiveIntervals.
In practice this has zero change AArch64/X86-64/RISC-V as measured on llvm-test-suite, but prevents weights from being perturbed in an upcoming patch which enables more rematerialization by re-attempting https://reviews.llvm.org/D1064081 parent ec8819f commit e8a2bb4
File tree
17 files changed
+986
-954
lines changed- llvm
- include/llvm/CodeGen
- lib/CodeGen
- test/CodeGen
- RISCV/rvv
- Thumb2/LowOverheadLoops
17 files changed
+986
-954
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 196 | | |
202 | 197 | | |
203 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
127 | 138 | | |
128 | 139 | | |
129 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
1820 | 1821 | | |
1821 | 1822 | | |
1822 | 1823 | | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 104 | | |
159 | 105 | | |
160 | 106 | | |
| |||
164 | 110 | | |
165 | 111 | | |
166 | 112 | | |
167 | | - | |
168 | 113 | | |
169 | | - | |
170 | 114 | | |
171 | 115 | | |
172 | | - | |
| 116 | + | |
173 | 117 | | |
174 | 118 | | |
175 | 119 | | |
| |||
230 | 174 | | |
231 | 175 | | |
232 | 176 | | |
233 | | - | |
234 | | - | |
| 177 | + | |
235 | 178 | | |
236 | 179 | | |
237 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2025 | 2025 | | |
2026 | 2026 | | |
2027 | 2027 | | |
2028 | | - | |
| 2028 | + | |
| 2029 | + | |
2029 | 2030 | | |
2030 | 2031 | | |
2031 | 2032 | | |
| |||
2036 | 2037 | | |
2037 | 2038 | | |
2038 | 2039 | | |
2039 | | - | |
| 2040 | + | |
2040 | 2041 | | |
2041 | 2042 | | |
2042 | 2043 | | |
2043 | 2044 | | |
2044 | | - | |
| 2045 | + | |
2045 | 2046 | | |
2046 | | - | |
2047 | | - | |
| 2047 | + | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | | - | |
2051 | | - | |
2052 | | - | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
2056 | | - | |
| 2056 | + | |
2057 | 2057 | | |
2058 | | - | |
2059 | | - | |
| 2058 | + | |
| 2059 | + | |
2060 | 2060 | | |
2061 | 2061 | | |
2062 | 2062 | | |
2063 | 2063 | | |
2064 | 2064 | | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
2070 | 2070 | | |
2071 | 2071 | | |
2072 | 2072 | | |
2073 | | - | |
| 2073 | + | |
2074 | 2074 | | |
2075 | 2075 | | |
2076 | 2076 | | |
2077 | 2077 | | |
2078 | | - | |
| 2078 | + | |
2079 | 2079 | | |
2080 | | - | |
| 2080 | + | |
2081 | 2081 | | |
2082 | 2082 | | |
2083 | 2083 | | |
| |||
2098 | 2098 | | |
2099 | 2099 | | |
2100 | 2100 | | |
2101 | | - | |
| 2101 | + | |
| 2102 | + | |
2102 | 2103 | | |
2103 | 2104 | | |
2104 | 2105 | | |
2105 | 2106 | | |
2106 | 2107 | | |
2107 | 2108 | | |
2108 | | - | |
2109 | | - | |
| 2109 | + | |
2110 | 2110 | | |
2111 | 2111 | | |
2112 | 2112 | | |
2113 | | - | |
2114 | | - | |
| 2113 | + | |
| 2114 | + | |
2115 | 2115 | | |
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
2119 | 2119 | | |
2120 | | - | |
2121 | | - | |
2122 | | - | |
2123 | | - | |
2124 | | - | |
2125 | | - | |
2126 | | - | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
2127 | 2127 | | |
2128 | 2128 | | |
2129 | 2129 | | |
| |||
2263 | 2263 | | |
2264 | 2264 | | |
2265 | 2265 | | |
2266 | | - | |
| 2266 | + | |
2267 | 2267 | | |
2268 | 2268 | | |
2269 | 2269 | | |
2270 | | - | |
2271 | | - | |
| 2270 | + | |
| 2271 | + | |
2272 | 2272 | | |
2273 | 2273 | | |
2274 | 2274 | | |
2275 | 2275 | | |
2276 | 2276 | | |
2277 | | - | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
2278 | 2280 | | |
2279 | | - | |
2280 | | - | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | 2283 | | |
| |||
2312 | 2312 | | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | | - | |
| 2315 | + | |
2316 | 2316 | | |
2317 | 2317 | | |
2318 | 2318 | | |
2319 | 2319 | | |
2320 | 2320 | | |
2321 | | - | |
2322 | | - | |
2323 | | - | |
2324 | | - | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
2325 | 2325 | | |
2326 | 2326 | | |
2327 | 2327 | | |
| |||
0 commit comments