[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 12:18:54 PDT 2021
avl updated this revision to Diff 371690.
avl added a comment.
addressed comments.
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.371690.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210909/5af9600b/attachment.bin>
More information about the llvm-commits
mailing list