[PATCH] D102487: Avoid underestimating the number of DIEs for a given debug info size.

Simon Giesecke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 05:20:38 PDT 2021


simon.giesecke created this revision.
simon.giesecke added reviewers: clayborg, dblaikie.
simon.giesecke added a project: debug-info.
Herald added a subscriber: hiraditya.
simon.giesecke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102487

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
@@ -372,9 +372,9 @@
       if (!AppendNonCUDies)
         break;
       // The average bytes per DIE entry has been seen to be
-      // around 14-20 so let's pre-reserve the needed memory for
+      // around 6-12 so let's pre-reserve the needed memory for
       // our DIE entries accordingly.
-      Dies.reserve(Dies.size() + getDebugInfoSize() / 14);
+      Dies.reserve(Dies.size() + getDebugInfoSize() / 6);
       IsCUDie = false;
     } else {
       Dies.push_back(DIE);
@@ -394,6 +394,8 @@
     }
   }
 
+  Dies.shrink_to_fit();
+
   // Give a little bit of info if we encounter corrupt DWARF (our offset
   // should always terminate at or before the start of the next compilation
   // unit header).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102487.345407.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/878cf62f/attachment.bin>


More information about the llvm-commits mailing list