aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorVito Kortbeek <kortbeek@synopsys.com>2025-05-24 08:52:51 +0200
committerGitHub <noreply@github.com>2025-05-24 08:52:51 +0200
commite03b1b895e03bf404c4d254faa47356de516bb94 (patch)
tree898cb10c3dd7e3df81023118b956455fc6bdf52e /llvm/lib/CodeGen/MachineBasicBlock.cpp
parentb5663d02a7928856aff116e534c8d895ed4622e5 (diff)
downloadllvm-e03b1b895e03bf404c4d254faa47356de516bb94.zip
llvm-e03b1b895e03bf404c4d254faa47356de516bb94.tar.gz
llvm-e03b1b895e03bf404c4d254faa47356de516bb94.tar.bz2
[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 (https://github.com/llvm/llvm-project/pull/71026#discussion_r2000595214) 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 https://github.com/llvm/llvm-project/pull/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 !
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
0 files changed, 0 insertions, 0 deletions