diff options
author | Hendrik Greving <hgreving@google.com> | 2022-05-25 15:18:55 +0000 |
---|---|---|
committer | Hendrik Greving <hgreving@google.com> | 2022-06-06 19:52:28 +0000 |
commit | a43d25734a46788da47a1a3786b3cd2bca540a72 (patch) | |
tree | 4fc80fd60954d50751ca02a6a3fd3aa88c743124 /llvm/lib/CodeGen/ModuloSchedule.cpp | |
parent | d1346e2ee2741919a8cc1b1ffe400001e76a6d06 (diff) | |
download | llvm-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.cpp | 6 |
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) { |