[llvm] [AMDGPU] Fix end() iterator dereference in SILowerSGPRSpills (PR #88828)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 06:55:36 PDT 2024
================
@@ -278,7 +278,10 @@ void SILowerSGPRSpills::extendWWMVirtRegLiveness(MachineFunction &MF,
for (auto Reg : MFI->getSGPRSpillVGPRs()) {
for (MachineBasicBlock *SaveBlock : SaveBlocks) {
MachineBasicBlock::iterator InsertBefore = SaveBlock->begin();
- auto MIB = BuildMI(*SaveBlock, *InsertBefore, InsertBefore->getDebugLoc(),
+ DebugLoc DL = InsertBefore != SaveBlock->end()
+ ? InsertBefore->getDebugLoc()
+ : DebugLoc();
----------------
jayfoad wrote:
This looks like a job for `MachineBasicBlock::findDebugLoc` (not that I've ever used it myself):
```suggestion
DebugLoc DL = SaveBlock->findDebugLoc(InsertBefore);
```
https://github.com/llvm/llvm-project/pull/88828
More information about the llvm-commits
mailing list