[PATCH] D118677: [llvm-profgen] Clean up unnecessary memory reservations between phases.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 12:49:00 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG057e784b0962: [llvm-profgen] Clean up unnecessary memory reservations between phases. (authored by hoy).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118677/new/

https://reviews.llvm.org/D118677

Files:
  llvm/tools/llvm-profgen/PerfReader.cpp
  llvm/tools/llvm-profgen/llvm-profgen.cpp


Index: llvm/tools/llvm-profgen/llvm-profgen.cpp
===================================================================
--- llvm/tools/llvm-profgen/llvm-profgen.cpp
+++ llvm/tools/llvm-profgen/llvm-profgen.cpp
@@ -158,6 +158,9 @@
       ProfileGeneratorBase::create(Binary.get(), Reader->getSampleCounters(),
                                    Reader->profileIsCSFlat());
   Generator->generateProfile();
+  // The Reader object, espcially its SampleCounters field, is not needed at
+  // this point, so releasing it to reduce peak memory usage.
+  Reader.release();
   Generator->write();
 
   return EXIT_SUCCESS;
Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ llvm/tools/llvm-profgen/PerfReader.cpp
@@ -1212,6 +1212,7 @@
   warnTruncatedStack();
   warnInvalidRange();
   generateUnsymbolizedProfile();
+  AggregatedSamples.clear();
 
   if (SkipSymbolization)
     writeUnsymbolizedProfile(OutputFilename);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118677.405070.patch
Type: text/x-patch
Size: 1022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/8e95715f/attachment.bin>


More information about the llvm-commits mailing list