Commit e03b1b8
authored
[CodeGen][MachineLoop] Fix getLoopID (#137820)
Mirror the `getLoopID()` implementation of `LoopInfo` in
`MachineLoopInfo`.
`getLoopID` used `findLoopControlBlock` to detect the special case where
there is a single latch. However, `findLoopControlBlock` returns the
exiting block if the latch is not an exiting block. The middle end
places the `LoopID` metadata on the
latch regardless of if it's an exiting block or not.
I raised this issue in the PR that introduced the `getLoopID()` helper
(#71026 (comment))
and @FreddyLeaf confirmed this is a bug and asked me to help implement a
refinement.
I've mirrored the implementation of `LoopInfo` instead of simply
changing `findLoopControlBlock()` to `findLoopControlBlock()` to keep
the two implementations consistent. The only difference between the two
is that `MachineLoopInfo::getLoopID` initially starts out with a
`MachineBacisBlock` and attempts to retrieve the `BasicBlock` (if it
wasn't for this difference, I would have moved it to `genericLoopInfo`).
I've also updated the test associated with
#71026 (`test5`) that check the
alignment for a loop with a single latch that's not the exit. This test
will fail for the current implementation. I'm not sure if we want to
include this test upstream (it might look out of place after we remove
the 'single-latch-specialization' from `getLoopID()`).
Let me know if you have any comments, @FreddyLeaf !1 parent b5663d0 commit e03b1b8
File tree
2 files changed
+64
-38
lines changed- llvm
- lib/CodeGen
- test/CodeGen/X86
2 files changed
+64
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | | - | |
186 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
222 | 204 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
226 | 210 | | |
227 | 211 | | |
228 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
180 | 222 | | |
181 | 223 | | |
182 | 224 | | |
| |||
0 commit comments