[llvm] [AMDGPU] Fix crash in SIInsertWaitcnts debug output (PR #175518)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 12 03:10:12 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 543876e33..fa48dbc5a 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1649,13 +1649,12 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
Wait.ExpCnt = ~0u;
Wait.DsCnt = ~0u;
- LLVM_DEBUG(It.isEnd()
- ? dbgs()
- << "applied pre-existing waitcnt\n"
- << "New Instr at block end: " << *WaitcntInstr << '\n'
- : dbgs() << "applied pre-existing waitcnt\n"
- << "Old Instr: " << *It
- << "New Instr: " << *WaitcntInstr << '\n');
+ LLVM_DEBUG(It.isEnd() ? dbgs() << "applied pre-existing waitcnt\n"
+ << "New Instr at block end: "
+ << *WaitcntInstr << '\n'
+ : dbgs() << "applied pre-existing waitcnt\n"
+ << "Old Instr: " << *It
+ << "New Instr: " << *WaitcntInstr << '\n');
}
if (WaitcntVsCntInstr) {
@@ -1877,13 +1876,12 @@ bool WaitcntGeneratorGFX12Plus::applyPreexistingWaitcnt(
Wait.LoadCnt = ~0u;
Wait.DsCnt = ~0u;
- LLVM_DEBUG(It.isEnd()
- ? dbgs() << "applied pre-existing waitcnt\n"
- << "New Instr at block end: "
- << *CombinedLoadDsCntInstr << '\n'
- : dbgs() << "applied pre-existing waitcnt\n"
- << "Old Instr: " << *It << "New Instr: "
- << *CombinedLoadDsCntInstr << '\n');
+ LLVM_DEBUG(It.isEnd() ? dbgs() << "applied pre-existing waitcnt\n"
+ << "New Instr at block end: "
+ << *CombinedLoadDsCntInstr << '\n'
+ : dbgs() << "applied pre-existing waitcnt\n"
+ << "Old Instr: " << *It << "New Instr: "
+ << *CombinedLoadDsCntInstr << '\n');
} else {
CombinedLoadDsCntInstr->eraseFromParent();
Modified = true;
@@ -1902,13 +1900,12 @@ bool WaitcntGeneratorGFX12Plus::applyPreexistingWaitcnt(
Wait.StoreCnt = ~0u;
Wait.DsCnt = ~0u;
- LLVM_DEBUG(It.isEnd()
- ? dbgs() << "applied pre-existing waitcnt\n"
- << "New Instr at block end: "
- << *CombinedStoreDsCntInstr << '\n'
- : dbgs() << "applied pre-existing waitcnt\n"
- << "Old Instr: " << *It << "New Instr: "
- << *CombinedStoreDsCntInstr << '\n');
+ LLVM_DEBUG(It.isEnd() ? dbgs() << "applied pre-existing waitcnt\n"
+ << "New Instr at block end: "
+ << *CombinedStoreDsCntInstr << '\n'
+ : dbgs() << "applied pre-existing waitcnt\n"
+ << "Old Instr: " << *It << "New Instr: "
+ << *CombinedStoreDsCntInstr << '\n');
} else {
CombinedStoreDsCntInstr->eraseFromParent();
Modified = true;
@@ -1994,13 +1991,12 @@ bool WaitcntGeneratorGFX12Plus::applyPreexistingWaitcnt(
if (Enc != (unsigned)AMDGPU::DepCtr::getDefaultDepCtrEncoding(*ST)) {
Modified |= updateOperandIfDifferent(*WaitcntDepctrInstr,
AMDGPU::OpName::simm16, Enc);
- LLVM_DEBUG(It.isEnd()
- ? dbgs() << "applyPreexistingWaitcnt\n"
- << "New Instr at block end: "
- << *WaitcntDepctrInstr << '\n'
- : dbgs() << "applyPreexistingWaitcnt\n"
- << "Old Instr: " << *It
- << "New Instr: " << *WaitcntDepctrInstr << '\n');
+ LLVM_DEBUG(It.isEnd() ? dbgs() << "applyPreexistingWaitcnt\n"
+ << "New Instr at block end: "
+ << *WaitcntDepctrInstr << '\n'
+ : dbgs() << "applyPreexistingWaitcnt\n"
+ << "Old Instr: " << *It << "New Instr: "
+ << *WaitcntDepctrInstr << '\n');
} else {
WaitcntDepctrInstr->eraseFromParent();
Modified = true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/175518
More information about the llvm-commits
mailing list