aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2022-02-02 15:54:24 +0000
committerJeremy Morse <jeremy.morse@sony.com>2022-02-02 16:01:11 +0000
commit206cafb680cea0741f8c7b276351db516ff27f81 (patch)
tree0a92a95859ecda305376e9728fc1a5ba2f9b354a /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
parent49d6e3eb332d0cf4a312eaf7a25e1fb72c0d447d (diff)
downloadllvm-206cafb680cea0741f8c7b276351db516ff27f81.zip
llvm-206cafb680cea0741f8c7b276351db516ff27f81.tar.gz
llvm-206cafb680cea0741f8c7b276351db516ff27f81.tar.bz2
Follow up to 9fd9d56dc6b, avoid a memory leak
Gaps in the basic block number range (from blocks being deleted or folded) get block-value-tables allocated but never ejected, leading to a memory leak, currently tripping up the asan buildbots. Fix this up by manually freeing that memory. As suggested elsewhere, if these things were owned by a unique_ptr then cleanup would happen automagically. D118774 should eliminate the need for this dance.
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 55e5154..3b4d717 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -3032,6 +3032,16 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
if (MOutLocs[MBB->getNumber()])
EjectBlock(*MBB);
+ // Finally, there might have been gaps in the block numbering, from dead
+ // blocks being deleted or folded. In those scenarios, we might allocate a
+ // block-table that's never ejected, meaning we have to free it at the end.
+ for (unsigned int I = 0; I < MaxNumBlocks; ++I) {
+ if (MInLocs[I]) {
+ delete[] MInLocs[I];
+ delete[] MOutLocs[I];
+ }
+ }
+
return emitTransfers(AllVarsNumbering);
}