[PATCH] D109499: [DebugInfo][NFC] Erase capacity in DWARFUnit::clearDIEs().
Alexey Lapshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 9 04:02:25 PDT 2021
avl created this revision.
avl added reviewers: dblaikie, labath, JDevlieghere.
Herald added a subscriber: hiraditya.
avl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
DWARFUnit::clearDIEs() uses std::vector::shrink_to_fit() to make
capacity of DieArray matched with its size(). The shrink_to_fit()
is not binding request to make capacity match with size().
Thus the memory could still be reserved after DWARFUnit::clearDIEs()
is called. This patch erases capacity when DWARFUnit::clearDIEs() is requested.
So the memory occupied by dies would be freed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109499
Files:
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
@@ -577,10 +577,12 @@
}
void DWARFUnit::clearDIEs(bool KeepCUDie) {
- if (DieArray.size() > (unsigned)KeepCUDie) {
- DieArray.resize((unsigned)KeepCUDie);
- DieArray.shrink_to_fit();
- }
+ if (KeepCUDie && DieArray.size() > 0) {
+ std::vector<DWARFDebugInfoEntry> VectorWithSingleCU(1);
+ VectorWithSingleCU.emplace_back(DieArray[0]);
+ DieArray = VectorWithSingleCU;
+ } else
+ DieArray = std::vector<DWARFDebugInfoEntry>(0);
}
Expected<DWARFAddressRangesVector>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109499.371545.patch
Type: text/x-patch
Size: 694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210909/451d3bf8/attachment.bin>
More information about the llvm-commits
mailing list