[llvm] [AMDGPU] Fix excessive stack usage in SIInsertWaitcnts::run (PR #134835)
David Stuttard via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 03:57:06 PDT 2025
================
@@ -2623,12 +2623,17 @@ bool SIInsertWaitcnts::run(MachineFunction &MF) {
else
*Brackets = *BI.Incoming;
} else {
- if (!Brackets)
+ if (!Brackets) {
Brackets = std::make_unique<WaitcntBrackets>(
ST, MaxCounter, Limits, WaitEventMaskForInst, SmemAccessCounter);
- else
- *Brackets = WaitcntBrackets(ST, MaxCounter, Limits,
- WaitEventMaskForInst, SmemAccessCounter);
+ } else {
+ // Reinitialize in-place. N.B. do not do this by assigning from a
+ // temporary because the WaitcntBrackets class is large and it could
+ // cause this function to use an unreasonable amount of stack space.
+ Brackets->~WaitcntBrackets();
+ new (Brackets.get()) WaitcntBrackets(
----------------
dstutt wrote:
Is this placement-new syntax?
https://github.com/llvm/llvm-project/pull/134835
More information about the llvm-commits
mailing list