[llvm] [DebugInfo] Fix memory leak in DebugSSAUpdater (PR #159107)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 07:49:06 PDT 2025
https://github.com/SLTozer created https://github.com/llvm/llvm-project/pull/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.
>From 18563233a6fd0abc031ec495367a1563c6dc276e Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Tue, 16 Sep 2025 15:37:05 +0100
Subject: [PATCH] [DebugInfo] Fix memory leak in DebugSSAUpdater
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.
---
llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h | 5 +++++
1 file changed, 5 insertions(+)
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