aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/ModuloSchedule.cpp
diff options
context:
space:
mode:
authorHendrik Greving <hgreving@google.com>2022-05-25 15:18:55 +0000
committerHendrik Greving <hgreving@google.com>2022-06-06 19:52:28 +0000
commita43d25734a46788da47a1a3786b3cd2bca540a72 (patch)
tree4fc80fd60954d50751ca02a6a3fd3aa88c743124 /llvm/lib/CodeGen/ModuloSchedule.cpp
parentd1346e2ee2741919a8cc1b1ffe400001e76a6d06 (diff)
downloadllvm-a43d25734a46788da47a1a3786b3cd2bca540a72.zip
llvm-a43d25734a46788da47a1a3786b3cd2bca540a72.tar.gz
llvm-a43d25734a46788da47a1a3786b3cd2bca540a72.tar.bz2
[ModuloSchedule] Fix terminator update when peeling.
Fixes a bug of us not correctly updating the terminator of the loop's preheader, if multiple terminating branch instructions are present. This is tested through existing tests. The bug itself is hard or not possible to get exposed with the upstream Hexagon backend, because the machine pipeliner checks for an existing preheader, which is defined as a block with only 1 edge into the header. The condition of this bug is a block into the loop with more than 1 edge, and not every downstream target checks for an existing preheader. Differential Revision: https://reviews.llvm.org/D126386
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
-rw-r--r--llvm/lib/CodeGen/ModuloSchedule.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index 20aecdf..767c484 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -1797,10 +1797,10 @@ void PeelingModuloScheduleExpander::peelPrologAndEpilogs() {
// Iterate in reverse order over all instructions, remapping as we go.
for (MachineBasicBlock *B : reverse(Blocks)) {
- for (auto I = B->getFirstInstrTerminator()->getReverseIterator();
+ for (auto I = B->instr_rbegin();
I != std::next(B->getFirstNonPHI()->getReverseIterator());) {
- MachineInstr *MI = &*I++;
- rewriteUsesOf(MI);
+ MachineBasicBlock::reverse_instr_iterator MI = I++;
+ rewriteUsesOf(&*MI);
}
}
for (auto *MI : IllegalPhisToDelete) {