Skip to content

Commit 206cafb

Browse files
committed
Follow up to 9fd9d56, 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.
1 parent 49d6e3e commit 206cafb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,16 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
30323032
if (MOutLocs[MBB->getNumber()])
30333033
EjectBlock(*MBB);
30343034

3035+
// Finally, there might have been gaps in the block numbering, from dead
3036+
// blocks being deleted or folded. In those scenarios, we might allocate a
3037+
// block-table that's never ejected, meaning we have to free it at the end.
3038+
for (unsigned int I = 0; I < MaxNumBlocks; ++I) {
3039+
if (MInLocs[I]) {
3040+
delete[] MInLocs[I];
3041+
delete[] MOutLocs[I];
3042+
}
3043+
}
3044+
30353045
return emitTransfers(AllVarsNumbering);
30363046
}
30373047

0 commit comments

Comments
 (0)