From 18563233a6fd0abc031ec495367a1563c6dc276e Mon Sep 17 00:00:00 2001 From: Stephen Tozer 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;