[llvm] [AMDGPU][SIInsertWaitcnts] don't crash when printing messages at end of block (PR #145694)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 05:53:29 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Sameer Sahasrabuddhe (ssahasra)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/145694.diff
1 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp (+13-2)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index f43831016952a..98e1696056f11 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1353,7 +1353,14 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
MachineInstr *WaitcntInstr = nullptr;
MachineInstr *WaitcntVsCntInstr = nullptr;
- LLVM_DEBUG(dbgs() << "PreGFX12::applyPreexistingWaitcnt at: " << *It);
+ // clang-format off
+ LLVM_DEBUG(dbgs() << "PreGFX12::applyPreexistingWaitcnt at: ";
+ if (It == OldWaitcntInstr.getParent()->instr_end())
+ dbgs() << "end of block\n";
+ else
+ dbgs() << *It;
+ );
+ // clang-format on
for (auto &II :
make_early_inc_range(make_range(OldWaitcntInstr.getIterator(), It))) {
@@ -1377,6 +1384,7 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
// Merge consecutive waitcnt of the same type by erasing multiples.
if (WaitcntInstr || (!Wait.hasWaitExceptStoreCnt() && TrySimplify)) {
+ LLVM_DEBUG(dbgs() << "erased waitcnt: " << II);
II.eraseFromParent();
Modified = true;
} else
@@ -1507,7 +1515,10 @@ bool WaitcntGeneratorGFX12Plus::applyPreexistingWaitcnt(
MachineInstr *CombinedStoreDsCntInstr = nullptr;
MachineInstr *WaitInstrs[NUM_EXTENDED_INST_CNTS] = {};
- LLVM_DEBUG(dbgs() << "GFX12Plus::applyPreexistingWaitcnt at: " << *It);
+ LLVM_DEBUG(dbgs() << "GFX12Plus::applyPreexistingWaitcnt at: ";
+ if (It == OldWaitcntInstr.getParent()->instr_end()) dbgs()
+ << "end of block\n";
+ else dbgs() << *It);
for (auto &II :
make_early_inc_range(make_range(OldWaitcntInstr.getIterator(), It))) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/145694
More information about the llvm-commits
mailing list