[PATCH] D62623: Reduce memory consumption of coverage dumps
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 4 03:35:59 PDT 2019
serge-sans-paille updated this revision to Diff 202896.
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.
Update comment + force reduced memory consumption.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62623/new/
https://reviews.llvm.org/D62623
Files:
clang/lib/CodeGen/CoverageMappingGen.cpp
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===================================================================
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1388,10 +1388,19 @@
std::string FilenamesAndCoverageMappings;
llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
- std::string RawCoverageMappings =
- llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
- OS << RawCoverageMappings;
- size_t CoverageMappingSize = RawCoverageMappings.size();
+
+ // Stream the content of CoverageMappings to OS while keeping
+ // memory consumption under control.
+ size_t CoverageMappingSize = 0;
+ for (auto &S : CoverageMappings) {
+ CoverageMappingSize += S.size();
+ OS << S;
+ S.clear();
+ S.shrink_to_fit();
+ }
+ CoverageMappings.clear();
+ CoverageMappings.shrink_to_fit();
+
size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
// Append extra zeroes if necessary to ensure that the size of the filenames
// and coverage mappings is a multiple of 8.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62623.202896.patch
Type: text/x-patch
Size: 1134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190604/3281098a/attachment.bin>
More information about the cfe-commits
mailing list