[llvm] 0dd0359 - Revert "[AMDGPU] Fix excessive stack usage in SIInsertWaitcnts::run (#134835)" (#174215)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 5 04:10:16 PST 2026


Author: Jay Foad
Date: 2026-01-05T12:10:11Z
New Revision: 0dd03598dca91c93c74b94a714c38a4ffad0ed1c

URL: https://github.com/llvm/llvm-project/commit/0dd03598dca91c93c74b94a714c38a4ffad0ed1c
DIFF: https://github.com/llvm/llvm-project/commit/0dd03598dca91c93c74b94a714c38a4ffad0ed1c.diff

LOG: Revert "[AMDGPU] Fix excessive stack usage in SIInsertWaitcnts::run (#134835)" (#174215)

This reverts commit 008c875be85732f72c4df4671167f5be79f449eb.

PR #162077 / #171779 shrunk the WaitcntBrackets class by using DenseMaps
instead of large arrays, so the size of a temporary WaitcntBrackets
allocated on the stack is no longer a concern.

With this patch on Linux I measured the stack size of
SIInsertWaitcnts::run increasing from 456 bytes to 632 bytes.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index e912440784c55..4901a9a8d4d4c 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -2915,15 +2915,10 @@ bool SIInsertWaitcnts::run(MachineFunction &MF) {
         else
           *Brackets = *BI.Incoming;
       } else {
-        if (!Brackets) {
+        if (!Brackets)
           Brackets = std::make_unique<WaitcntBrackets>(this);
-        } 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(this);
-        }
+        else
+          *Brackets = WaitcntBrackets(this);
       }
 
       Modified |= insertWaitcntInBlock(MF, *MBB, *Brackets);


        


More information about the llvm-commits mailing list