[RISCV] Add the DebugLoc parameter to getVLENFactoredAmount().
authorHsiangkai Wang <kai.wang@sifive.com>
Thu, 13 May 2021 02:45:00 +0000 (10:45 +0800)
committerHsiangkai Wang <kai.wang@sifive.com>
Fri, 14 May 2021 13:31:06 +0000 (21:31 +0800)
commitb41e1306b80f20a857f0e285e51ea453eb7888a1
tree78e9ff4167f3ce326ef150eacd768f7295791702
parent3d59f9d22440645ca0237dfc5d91ca09f749174b
[RISCV] Add the DebugLoc parameter to getVLENFactoredAmount().

The MachineBasicBlock::iterator is continuously changing during
generating the frame handling instructions. We should use the DebugLoc
from the caller, instead of getting it from the changing iterator.

If the prologue instructions located in a basic block without any other
instructions after these prologue instructions, the iterator will be
updated to the boundary of the basic block and it is invalid to use the
iterator to access DebugLoc. This patch also fixes the crash when
accessing DebugLoc using the iterator.

Differential Revision: https://reviews.llvm.org/D102386
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.h
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir [new file with mode: 0644]