Skip to content

Commit 81e0799

Browse files
authored
[AMDGPU][SIInsertWaitcnts] don't crash when printing messages at end of block (#145694)
1 parent 60285d9 commit 81e0799

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,13 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
13531353
MachineInstr *WaitcntInstr = nullptr;
13541354
MachineInstr *WaitcntVsCntInstr = nullptr;
13551355

1356-
LLVM_DEBUG(dbgs() << "PreGFX12::applyPreexistingWaitcnt at: " << *It);
1356+
LLVM_DEBUG({
1357+
dbgs() << "PreGFX12::applyPreexistingWaitcnt at: ";
1358+
if (It == OldWaitcntInstr.getParent()->instr_end())
1359+
dbgs() << "end of block\n";
1360+
else
1361+
dbgs() << *It;
1362+
});
13571363

13581364
for (auto &II :
13591365
make_early_inc_range(make_range(OldWaitcntInstr.getIterator(), It))) {
@@ -1507,7 +1513,13 @@ bool WaitcntGeneratorGFX12Plus::applyPreexistingWaitcnt(
15071513
MachineInstr *CombinedStoreDsCntInstr = nullptr;
15081514
MachineInstr *WaitInstrs[NUM_EXTENDED_INST_CNTS] = {};
15091515

1510-
LLVM_DEBUG(dbgs() << "GFX12Plus::applyPreexistingWaitcnt at: " << *It);
1516+
LLVM_DEBUG({
1517+
dbgs() << "GFX12Plus::applyPreexistingWaitcnt at: ";
1518+
if (It == OldWaitcntInstr.getParent()->instr_end())
1519+
dbgs() << "end of block\n";
1520+
else
1521+
dbgs() << *It;
1522+
});
15111523

15121524
for (auto &II :
15131525
make_early_inc_range(make_range(OldWaitcntInstr.getIterator(), It))) {

0 commit comments

Comments
 (0)