[llvm] a42aac5 - [DebugInfo] Fix memory leak in DebugSSAUpdater (#159107)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 07:49:40 PDT 2025


Author: Stephen Tozer
Date: 2025-09-16T15:49:36+01:00
New Revision: a42aac5f83e272f83207844dde1530b86e6fcf2b

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

LOG: [DebugInfo] Fix memory leak in DebugSSAUpdater (#159107)

Fixes an issue in commit 3946c50, PR #135349.

The DebugSSAUpdater class performs raw pointer allocations. It frees
these properly in reset(), but does not do so in its destructor - as an
immediate fix, this patch adds a destructor which frees the allocations
correctly.

I'll be merging this immediately to fix the issue, but will be open to
post-commit review and/or producing a better fix in a follow-up commit.

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
index 90899c86f5c3b..2d25ce3245793 100644
--- a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
+++ b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
@@ -235,6 +235,11 @@ class DebugSSAUpdater {
   DebugSSAUpdater(const DebugSSAUpdater &) = delete;
   DebugSSAUpdater &operator=(const DebugSSAUpdater &) = delete;
 
+  ~DebugSSAUpdater() {
+    for (auto &Block : BlockMap)
+      delete Block.second;
+  }
+
   void reset() {
     for (auto &Block : BlockMap)
       delete Block.second;


        


More information about the llvm-commits mailing list