[PATCH] D27959: Use exact vector capacities to store DWARF line tables

Simon Que via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 17:02:02 PST 2016


sque created this revision.
sque added a reviewer: echristo.
sque added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

A large binary's DWARF info can contain line tables with thousands of entries. Since dynamically resized vectors don't have exact capacities, there could be a large amount of wasted space. This patch changes the DWARF reader to store the line table rows in vectors with exact capacities.


https://reviews.llvm.org/D27959

Files:
  lib/DebugInfo/DWARF/DWARFDebugLine.cpp


Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -520,6 +520,11 @@
     // rudimentary sequences for address ranges [0x0, 0xsomething).
   }
 
+  // There could be hundreds or thousands of Rows in the line table. The vector
+  // will likely have an internal reserved memory block that is much bigger
+  // than necessary. Reduce the reserved capacity to conserve memroy.
+  Rows.shrink_to_fit();
+
   return end_offset;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27959.82040.patch
Type: text/x-patch
Size: 580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161220/26588bcf/attachment.bin>


More information about the llvm-commits mailing list