[PATCH] D90006: Exposes interface to free up caching data structure in DWARFDebugLine and DWARFUnit for memory management
Florin Papa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 20:20:02 PDT 2022
florinpapa updated this revision to Diff 418114.
florinpapa added a comment.
Rebase against origin/master
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90006/new/
https://reviews.llvm.org/D90006
Files:
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -370,6 +370,9 @@
AddrOffsetSectionBase = None;
SU = nullptr;
clearDIEs(false);
+ AddrDieMap.clear();
+ if (DWO)
+ DWO->clear();
DWO.reset();
}
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -601,6 +601,10 @@
return LT;
}
+void DWARFDebugLine::clearLineTable(uint64_t Offset) {
+ LineTableMap.erase(Offset);
+}
+
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase) {
assert(Opcode != 0);
if (Opcode < OpcodeBase)
Index: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -999,6 +999,22 @@
RecoverableErrorHandler);
}
+void DWARFContext::clearLineTableForUnit(DWARFUnit *U) {
+ if (!Line)
+ return;
+
+ auto UnitDIE = U->getUnitDIE();
+ if (!UnitDIE)
+ return;
+
+ auto Offset = toSectionOffset(UnitDIE.find(DW_AT_stmt_list));
+ if (!Offset)
+ return;
+
+ uint64_t stmtOffset = *Offset + U->getLineTableOffset();
+ Line->clearLineTable(stmtOffset);
+}
+
void DWARFContext::parseNormalUnits() {
if (!NormalUnits.empty())
return;
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
@@ -304,6 +304,7 @@
getOrParseLineTable(DWARFDataExtractor &DebugLineData, uint64_t Offset,
const DWARFContext &Ctx, const DWARFUnit *U,
function_ref<void(Error)> RecoverableErrorHandler);
+ void clearLineTable(uint64_t Offset);
/// Helper to allow for parsing of an entire .debug_line section in sequence.
class SectionParser {
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -333,6 +333,10 @@
getLineTableForUnit(DWARFUnit *U,
function_ref<void(Error)> RecoverableErrorHandler);
+ // Clear the line table object corresponding to a compile unit for memory
+ // management purpose. When it's referred to again, it'll be re-populated.
+ void clearLineTableForUnit(DWARFUnit *U);
+
DataExtractor getStringExtractor() const {
return DataExtractor(DObj->getStrSection(), false, 0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90006.418114.patch
Type: text/x-patch
Size: 2868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220325/7f0f666b/attachment.bin>
More information about the llvm-commits
mailing list