aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2023-05-25 12:57:33 +0200
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2023-05-25 14:48:52 +0200
commit63c9fe2db5cbaa7e068d24472d1aabed084789ce (patch)
tree3bebd1f43920cef6f8b975024b0d03db75249858 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parenta23f9846163956b74ab578bc972415c015022d10 (diff)
downloadllvm-63c9fe2db5cbaa7e068d24472d1aabed084789ce.zip
llvm-63c9fe2db5cbaa7e068d24472d1aabed084789ce.tar.gz
llvm-63c9fe2db5cbaa7e068d24472d1aabed084789ce.tar.bz2
[CodeGen] Fix for MachineBasicBlock::rfindDebugLoc(instr_rend())
Make sure we do not crash in rfindDebugLoc when starting at instr_rend(). Solution is to see it as we start one MI before the first MI, so we can start searching forward at instr_begin() instead. This behavior is similar to how findPrevDebugLoc(instr_end()) works. Differential Revision: https://reviews.llvm.org/D150577
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 1e92318..6a1d5ee 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1474,6 +1474,8 @@ MachineBasicBlock::findDebugLoc(instr_iterator MBBI) {
}
DebugLoc MachineBasicBlock::rfindDebugLoc(reverse_instr_iterator MBBI) {
+ if (MBBI == instr_rend())
+ return findDebugLoc(instr_begin());
// Skip debug declarations, we don't want a DebugLoc from them.
MBBI = skipDebugInstructionsBackward(MBBI, instr_rbegin());
if (!MBBI->isDebugInstr())