[PATCH] D109499: [DebugInfo][NFC] Erase capacity in DWARFUnit::clearDIEs().
Alexey Lapshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 00:07:45 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG349354083059: [DebugInfo][NFC] Erase capacity in DWARFUnit::clearDIEs(). (authored by avl).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109499/new/
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,14 @@
}
void DWARFUnit::clearDIEs(bool KeepCUDie) {
- if (DieArray.size() > (unsigned)KeepCUDie) {
- DieArray.resize((unsigned)KeepCUDie);
- DieArray.shrink_to_fit();
- }
+ // Do not use resize() + shrink_to_fit() to free memory occupied by dies.
+ // shrink_to_fit() is a *non-binding* request to reduce capacity() to size().
+ // It depends on the implementation whether the request is fulfilled.
+ // Create a new vector with a small capacity and assign it to the DieArray to
+ // have previous contents freed.
+ DieArray = (KeepCUDie && !DieArray.empty())
+ ? std::vector<DWARFDebugInfoEntry>({DieArray[0]})
+ : std::vector<DWARFDebugInfoEntry>();
}
Expected<DWARFAddressRangesVector>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109499.371796.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210910/ecdf0b45/attachment.bin>
More information about the llvm-commits
mailing list