Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -520,6 +520,15 @@ // 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. Copy the contents to a block of memory with the exact size + // (or as exact as the allocator will allow). + std::vector compactRows; + compactRows.reserve(Rows.size()); + std::copy(Rows.begin(), Rows.end(), compactRows.begin()); + Rows = std::move(compactRows); + return end_offset; }