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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Stephen Tozer (SLTozer)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/159107.diff


1 Files Affected:

- (modified) llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h (+5) 


``````````diff
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;

``````````

</details>


https://github.com/llvm/llvm-project/pull/159107


More information about the llvm-commits mailing list