From 56926ae0faa67ac4c3b75609bfeea2eb324c0851 Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Tue, 12 May 2020 14:48:22 -0700 Subject: [PATCH] [SampleFDO] Rename llvm-profdata flag -partial-profile to -gen-partial-profile. The internal flag -partial-profile in llvm conflicts with the flag with the same name in llvm-profdata. The conflict happens in builds with LLVM_LINK_LLVM_DYLIB enabled. In this case the tools are linked with libLLVM and we end up with two definitions for the same cl::opt. The patch renames llvm-profdata flag -partial-profile to -gen-partial-profile. --- llvm/test/tools/llvm-profdata/show-prof-info.test | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/llvm/test/tools/llvm-profdata/show-prof-info.test b/llvm/test/tools/llvm-profdata/show-prof-info.test index ca91051..4a74866 100644 --- a/llvm/test/tools/llvm-profdata/show-prof-info.test +++ b/llvm/test/tools/llvm-profdata/show-prof-info.test @@ -1,5 +1,5 @@ REQUIRES: zlib -; RUN: llvm-profdata merge -sample -extbinary -use-md5 -compress-all-sections -partial-profile -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output +; RUN: llvm-profdata merge -sample -extbinary -use-md5 -compress-all-sections -gen-partial-profile -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output ; RUN: wc -c < %t.1.output > %t.txt ; RUN: llvm-profdata show -sample -show-sec-info-only %t.1.output >> %t.txt ; RUN: FileCheck %s --input-file=%t.txt diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 6d2f636..3d0e820 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -449,7 +449,7 @@ static void handleExtBinaryWriter(sampleprof::SampleProfileWriter &Writer, MemoryBuffer *Buffer, sampleprof::ProfileSymbolList &WriterList, bool CompressAllSections, bool UseMD5, - bool PartialProfile) { + bool GenPartialProfile) { populateProfileSymbolList(Buffer, WriterList); if (WriterList.size() > 0 && OutputFormat != PF_Ext_Binary) warn("Profile Symbol list is not empty but the output format is not " @@ -469,9 +469,9 @@ static void handleExtBinaryWriter(sampleprof::SampleProfileWriter &Writer, else Writer.setUseMD5(); } - if (PartialProfile) { + if (GenPartialProfile) { if (OutputFormat != PF_Ext_Binary) - warn("-partial-profile is ignored. Specify -extbinary to enable it"); + warn("-gen-partial-profile is ignored. Specify -extbinary to enable it"); else Writer.setPartialProfile(); } @@ -481,7 +481,7 @@ static void mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper, StringRef OutputFilename, ProfileFormat OutputFormat, StringRef ProfileSymbolListFile, bool CompressAllSections, - bool UseMD5, bool PartialProfile, FailureMode FailMode) { + bool UseMD5, bool GenPartialProfile, FailureMode FailMode) { using namespace sampleprof; StringMap ProfileMap; SmallVector, 5> Readers; @@ -538,7 +538,7 @@ mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper, // Make sure Buffer lives as long as WriterList. auto Buffer = getInputFileBuf(ProfileSymbolListFile); handleExtBinaryWriter(*Writer, OutputFormat, Buffer.get(), WriterList, - CompressAllSections, UseMD5, PartialProfile); + CompressAllSections, UseMD5, GenPartialProfile); Writer->write(ProfileMap); } @@ -670,10 +670,9 @@ static int merge_main(int argc, const char *argv[]) { "use-md5", cl::init(false), cl::Hidden, cl::desc("Choose to use MD5 to represent string in name table (only " "meaningful for -extbinary)")); - cl::opt PartialProfile( - "partial-profile", cl::init(false), cl::Hidden, - cl::desc("Set the profile to be a partial profile (only meaningful " - "for -extbinary)")); + cl::opt GenPartialProfile( + "gen-partial-profile", cl::init(false), cl::Hidden, + cl::desc("Generate a partial profile (only meaningful for -extbinary)")); cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n"); @@ -708,7 +707,7 @@ static int merge_main(int argc, const char *argv[]) { else mergeSampleProfile(WeightedInputs, Remapper.get(), OutputFilename, OutputFormat, ProfileSymbolListFile, CompressAllSections, - UseMD5, PartialProfile, FailureMode); + UseMD5, GenPartialProfile, FailureMode); return 0; } -- 2.7.4