[PATCH] D139486: [llvm-profdata] Drop profile symbol list during merging AutoFDO profiles.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 16:41:05 PST 2022


hoy created this revision.
Herald added subscribers: modimo, wenlei.
Herald added a project: All.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Adding a switch to drop profile symbol list during merging AutoFDO profiles. This is needed to minimize the impact on default profiles when the profile symbol list is enabled for the source input profiles. The symbol list is quite large and could potentially slow down the compiler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139486

Files:
  llvm/test/tools/llvm-profdata/profile-symbol-list.test
  llvm/tools/llvm-profdata/llvm-profdata.cpp


Index: llvm/tools/llvm-profdata/llvm-profdata.cpp
===================================================================
--- llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -959,7 +959,8 @@
                    StringRef ProfileSymbolListFile, bool CompressAllSections,
                    bool UseMD5, bool GenPartialProfile, bool GenCSNestedProfile,
                    bool SampleMergeColdContext, bool SampleTrimColdContext,
-                   bool SampleColdContextFrameDepth, FailureMode FailMode) {
+                   bool SampleColdContextFrameDepth, FailureMode FailMode,
+                   bool DropProfileSymbolList) {
   using namespace sampleprof;
   SampleProfileMap ProfileMap;
   SmallVector<std::unique_ptr<sampleprof::SampleProfileReader>, 5> Readers;
@@ -1012,10 +1013,12 @@
       }
     }
 
-    std::unique_ptr<sampleprof::ProfileSymbolList> ReaderList =
-        Reader->getProfileSymbolList();
-    if (ReaderList)
-      WriterList.merge(*ReaderList);
+    if (!DropProfileSymbolList) {
+      std::unique_ptr<sampleprof::ProfileSymbolList> ReaderList =
+          Reader->getProfileSymbolList();
+      if (ReaderList)
+        WriterList.merge(*ReaderList);
+    }
   }
 
   if (ProfileIsCS && (SampleMergeColdContext || SampleTrimColdContext)) {
@@ -1227,6 +1230,9 @@
   cl::opt<std::string> ProfiledBinary(
       "profiled-binary", cl::init(""),
       cl::desc("Path to binary from which the profile was collected."));
+  cl::opt<bool> DropProfileSymbolList(
+      "drop-profile-symbol-list", cl::init(false), cl::Hidden,
+      cl::desc("Drop the profile symbol list when mergeing AutoFDO profiles"));
 
   cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n");
 
@@ -1271,11 +1277,11 @@
                       OutputFilename, OutputFormat, OutputSparse, NumThreads,
                       FailureMode, ProfiledBinary);
   else
-    mergeSampleProfile(WeightedInputs, Remapper.get(), OutputFilename,
-                       OutputFormat, ProfileSymbolListFile, CompressAllSections,
-                       UseMD5, GenPartialProfile, GenCSNestedProfile,
-                       SampleMergeColdContext, SampleTrimColdContext,
-                       SampleColdContextFrameDepth, FailureMode);
+    mergeSampleProfile(
+        WeightedInputs, Remapper.get(), OutputFilename, OutputFormat,
+        ProfileSymbolListFile, CompressAllSections, UseMD5, GenPartialProfile,
+        GenCSNestedProfile, SampleMergeColdContext, SampleTrimColdContext,
+        SampleColdContextFrameDepth, FailureMode, DropProfileSymbolList);
   return 0;
 }
 
Index: llvm/test/tools/llvm-profdata/profile-symbol-list.test
===================================================================
--- llvm/test/tools/llvm-profdata/profile-symbol-list.test
+++ llvm/test/tools/llvm-profdata/profile-symbol-list.test
@@ -3,3 +3,7 @@
 ; RUN: llvm-profdata merge -sample -extbinary %t.1.output %t.2.output -o %t.3.output
 ; RUN: llvm-profdata show -sample -show-prof-sym-list %t.3.output > %t.4.output
 ; RUN: diff -b %S/Inputs/profile-symbol-list.expected %t.4.output
+; RUN: llvm-profdata merge -sample -extbinary --drop-profile-symbol-list %t.1.output %t.2.output -o %t.5.output
+; RUN: llvm-profdata show -sample -show-sec-info-only %t.5.output  | FileCheck %s -check-prefix=NOSYMLIST
+
+; NOSYMLIST: ProfileSymbolListSection {{.*}} Size: 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139486.480688.patch
Type: text/x-patch
Size: 3403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221207/47c38f8c/attachment.bin>


More information about the llvm-commits mailing list