[CodeGen] Fix for MachineBasicBlock::rfindDebugLoc(instr_rend())
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Thu, 25 May 2023 10:57:33 +0000 (12:57 +0200)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Thu, 25 May 2023 12:48:52 +0000 (14:48 +0200)
commit63c9fe2db5cbaa7e068d24472d1aabed084789ce
tree3bebd1f43920cef6f8b975024b0d03db75249858
parenta23f9846163956b74ab578bc972415c015022d10
[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
llvm/lib/CodeGen/MachineBasicBlock.cpp
llvm/unittests/CodeGen/MachineBasicBlockTest.cpp