[compiler-rt] ea607d0 - [llvm-profdata] Rename show flag to --show-format

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 11:35:17 PDT 2022


Author: Ellis Hoag
Date: 2022-10-07T11:35:07-07:00
New Revision: ea607d033aff54b8be0fcc6d4931b0bfc5ebb252

URL: https://github.com/llvm/llvm-project/commit/ea607d033aff54b8be0fcc6d4931b0bfc5ebb252
DIFF: https://github.com/llvm/llvm-project/commit/ea607d033aff54b8be0fcc6d4931b0bfc5ebb252.diff

LOG: [llvm-profdata] Rename show flag to --show-format

In https://reviews.llvm.org/D135127 we created the show flag
`--output-format` which was confusing because it behaved differently
than the same flag in the merge command. So, rename the flag to
`--show-format`. This also allows us to add the `text` option to mean
"normal text output" rather than "text-encoded profiles" like it does
for the merge command.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D135467

Added: 
    

Modified: 
    compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
    llvm/docs/CommandGuide/llvm-profdata.rst
    llvm/test/tools/llvm-profdata/sample-profile-json.test
    llvm/tools/llvm-profdata/llvm-profdata.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
index a7ea54f208aec..f143901c82b18 100644
--- a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
+++ b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
@@ -1,6 +1,6 @@
 // RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
 // RUN: llvm-profdata show --debug-info=%t --detailed-summary --show-prof-sym-list | FileCheck %s
-// RUN: llvm-profdata show --debug-info=%t --output-format=yaml | FileCheck %s --match-full-lines --check-prefix YAML
+// RUN: llvm-profdata show --debug-info=%t --show-format=yaml | FileCheck %s --match-full-lines --check-prefix YAML
 
 // RUN: %clang_pgogen -o %t.no.dbg -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
 // RUN: not llvm-profdata show --debug-info=%t.no.dbg 2>&1 | FileCheck %s --check-prefix NO-DBG

diff  --git a/llvm/docs/CommandGuide/llvm-profdata.rst b/llvm/docs/CommandGuide/llvm-profdata.rst
index 12feed5eb690b..89a624555fe44 100644
--- a/llvm/docs/CommandGuide/llvm-profdata.rst
+++ b/llvm/docs/CommandGuide/llvm-profdata.rst
@@ -253,7 +253,7 @@ OPTIONS
 
  Print the counter values for the displayed functions.
 
-.. option:: --output-format=<json|yaml>
+.. option:: --show-format=<text|json|yaml>
 
  Emit output in the selected format if supported by the provided profile type.
 

diff  --git a/llvm/test/tools/llvm-profdata/sample-profile-json.test b/llvm/test/tools/llvm-profdata/sample-profile-json.test
index 9a19ab0c74e95..9e96693faace6 100644
--- a/llvm/test/tools/llvm-profdata/sample-profile-json.test
+++ b/llvm/test/tools/llvm-profdata/sample-profile-json.test
@@ -1,5 +1,5 @@
 RUN: llvm-profdata show --sample --json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
-RUN: llvm-profdata show --sample --output-format=json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
+RUN: llvm-profdata show --sample --show-format=json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
 JSON:      [
 JSON-NEXT:   {
 JSON-NEXT:     "name": "main",

diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 95019c96d9a2b..5e2067e9fd716 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -57,7 +57,7 @@ enum ProfileFormat {
   PF_Binary
 };
 
-enum class OutputFormat { None, Json, Yaml };
+enum class ShowFormat { Text, Json, Yaml };
 
 static void warn(Twine Message, std::string Whence = "",
                  std::string Hint = "") {
@@ -2254,11 +2254,11 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts,
                             uint64_t ValueCutoff, bool OnlyListBelow,
                             const std::string &ShowFunction, bool TextFormat,
                             bool ShowBinaryIds, bool ShowCovered,
-                            bool ShowProfileVersion, OutputFormat OFormat,
+                            bool ShowProfileVersion, ShowFormat SFormat,
                             raw_fd_ostream &OS) {
-  if (OFormat == OutputFormat::Json)
+  if (SFormat == ShowFormat::Json)
     exitWithError("JSON output is not supported for instr profiles");
-  if (OFormat == OutputFormat::Yaml)
+  if (SFormat == ShowFormat::Yaml)
     exitWithError("YAML output is not supported for instr profiles");
   auto ReaderOrErr = InstrProfReader::create(Filename);
   std::vector<uint32_t> Cutoffs = std::move(DetailedSummaryCutoffs);
@@ -2625,8 +2625,8 @@ static int showSampleProfile(const std::string &Filename, bool ShowCounts,
                              const std::string &ShowFunction,
                              bool ShowProfileSymbolList,
                              bool ShowSectionInfoOnly, bool ShowHotFuncList,
-                             OutputFormat OFormat, raw_fd_ostream &OS) {
-  if (OFormat == OutputFormat::Yaml)
+                             ShowFormat SFormat, raw_fd_ostream &OS) {
+  if (SFormat == ShowFormat::Yaml)
     exitWithError("YAML output is not supported for sample profiles");
   using namespace sampleprof;
   LLVMContext Context;
@@ -2645,12 +2645,12 @@ static int showSampleProfile(const std::string &Filename, bool ShowCounts,
     exitWithErrorCode(EC, Filename);
 
   if (ShowAllFunctions || ShowFunction.empty()) {
-    if (OFormat == OutputFormat::Json)
+    if (SFormat == ShowFormat::Json)
       Reader->dumpJson(OS);
     else
       Reader->dump(OS);
   } else {
-    if (OFormat == OutputFormat::Json)
+    if (SFormat == ShowFormat::Json)
       exitWithError(
           "the JSON format is supported only when all functions are to "
           "be printed");
@@ -2679,8 +2679,8 @@ static int showSampleProfile(const std::string &Filename, bool ShowCounts,
 
 static int showMemProfProfile(const std::string &Filename,
                               const std::string &ProfiledBinary,
-                              OutputFormat OFormat, raw_fd_ostream &OS) {
-  if (OFormat == OutputFormat::Json)
+                              ShowFormat SFormat, raw_fd_ostream &OS) {
+  if (SFormat == ShowFormat::Json)
     exitWithError("JSON output is not supported for MemProf");
   auto ReaderOr = llvm::memprof::RawMemProfReader::create(
       Filename, ProfiledBinary, /*KeepNames=*/true);
@@ -2700,13 +2700,13 @@ static int showMemProfProfile(const std::string &Filename,
 static int showDebugInfoCorrelation(const std::string &Filename,
                                     bool ShowDetailedSummary,
                                     bool ShowProfileSymbolList,
-                                    OutputFormat OFormat, raw_fd_ostream &OS) {
-  if (OFormat == OutputFormat::Json)
+                                    ShowFormat SFormat, raw_fd_ostream &OS) {
+  if (SFormat == ShowFormat::Json)
     exitWithError("JSON output is not supported for debug info correlation");
   std::unique_ptr<InstrProfCorrelator> Correlator;
   if (auto Err = InstrProfCorrelator::get(Filename).moveInto(Correlator))
     exitWithError(std::move(Err), Filename);
-  if (OFormat == OutputFormat::Yaml) {
+  if (SFormat == ShowFormat::Yaml) {
     if (auto Err = Correlator->dumpYaml(OS))
       exitWithError(std::move(Err), Filename);
     return 0;
@@ -2737,17 +2737,20 @@ static int show_main(int argc, const char *argv[]) {
 
   cl::opt<bool> ShowCounts("counts", cl::init(false),
                            cl::desc("Show counter values for shown functions"));
-  cl::opt<OutputFormat> OFormat(
-      "output-format", cl::init(OutputFormat::None),
+  cl::opt<ShowFormat> SFormat(
+      "show-format", cl::init(ShowFormat::Text),
       cl::desc("Emit output in the selected format if supported"),
-      cl::values(clEnumValN(OutputFormat::Json, "json", "emit JSON"),
-                 clEnumValN(OutputFormat::Yaml, "yaml", "emit YAML")));
+      cl::values(clEnumValN(ShowFormat::Text, "text",
+                            "emit normal text output (default)"),
+                 clEnumValN(ShowFormat::Json, "json", "emit JSON"),
+                 clEnumValN(ShowFormat::Yaml, "yaml", "emit YAML")));
+  // TODO: Consider replacing this with `--show-format=text-encoding`.
   cl::opt<bool> TextFormat(
       "text", cl::init(false),
       cl::desc("Show instr profile data in text dump format"));
   cl::opt<bool> JsonFormat(
       "json", cl::desc("Show sample profile data in the JSON format "
-                       "(deprecated, please use --output-format=json)"));
+                       "(deprecated, please use --show-format=json)"));
   cl::opt<bool> ShowIndirectCallTargets(
       "ic-targets", cl::init(false),
       cl::desc("Show indirect call site target values for shown functions"));
@@ -2827,7 +2830,7 @@ static int show_main(int argc, const char *argv[]) {
     return 1;
   }
   if (JsonFormat)
-    OFormat = OutputFormat::Json;
+    SFormat = ShowFormat::Json;
 
   std::error_code EC;
   raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_TextWithCRLF);
@@ -2839,21 +2842,21 @@ static int show_main(int argc, const char *argv[]) {
 
   if (!DebugInfoFilename.empty())
     return showDebugInfoCorrelation(DebugInfoFilename, ShowDetailedSummary,
-                                    ShowProfileSymbolList, OFormat, OS);
+                                    ShowProfileSymbolList, SFormat, OS);
 
   if (ProfileKind == instr)
     return showInstrProfile(
         Filename, ShowCounts, TopNFunctions, ShowIndirectCallTargets,
         ShowMemOPSizes, ShowDetailedSummary, DetailedSummaryCutoffs,
         ShowAllFunctions, ShowCS, ValueCutoff, OnlyListBelow, ShowFunction,
-        TextFormat, ShowBinaryIds, ShowCovered, ShowProfileVersion, OFormat,
+        TextFormat, ShowBinaryIds, ShowCovered, ShowProfileVersion, SFormat,
         OS);
   if (ProfileKind == sample)
     return showSampleProfile(Filename, ShowCounts, TopNFunctions,
                              ShowAllFunctions, ShowDetailedSummary,
                              ShowFunction, ShowProfileSymbolList,
-                             ShowSectionInfoOnly, ShowHotFuncList, OFormat, OS);
-  return showMemProfProfile(Filename, ProfiledBinary, OFormat, OS);
+                             ShowSectionInfoOnly, ShowHotFuncList, SFormat, OS);
+  return showMemProfProfile(Filename, ProfiledBinary, SFormat, OS);
 }
 
 int llvm_profdata_main(int argc, char **argvNonConst) {


        


More information about the llvm-commits mailing list