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 --- 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 --- a/llvm/docs/CommandGuide/llvm-profdata.rst +++ b/llvm/docs/CommandGuide/llvm-profdata.rst @@ -253,7 +253,7 @@ Print the counter values for the displayed functions. -.. option:: --output-format= +.. option:: --show-format= 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 --- 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 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -57,7 +57,7 @@ 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 @@ uint64_t ValueCutoff, bool OnlyListBelow, const std::string &ShowFunction, bool TextFormat, bool ShowBinaryIds, bool ShowCovered, - bool ShowProfileVersion, OutputFormat OFormat, + bool ShowProfileVersion, ShowFormat OFormat, raw_fd_ostream &OS) { - if (OFormat == OutputFormat::Json) + if (OFormat == ShowFormat::Json) exitWithError("JSON output is not supported for instr profiles"); - if (OFormat == OutputFormat::Yaml) + if (OFormat == ShowFormat::Yaml) exitWithError("YAML output is not supported for instr profiles"); auto ReaderOrErr = InstrProfReader::create(Filename); std::vector Cutoffs = std::move(DetailedSummaryCutoffs); @@ -2625,8 +2625,8 @@ const std::string &ShowFunction, bool ShowProfileSymbolList, bool ShowSectionInfoOnly, bool ShowHotFuncList, - OutputFormat OFormat, raw_fd_ostream &OS) { - if (OFormat == OutputFormat::Yaml) + ShowFormat OFormat, raw_fd_ostream &OS) { + if (OFormat == ShowFormat::Yaml) exitWithError("YAML output is not supported for sample profiles"); using namespace sampleprof; LLVMContext Context; @@ -2645,12 +2645,12 @@ exitWithErrorCode(EC, Filename); if (ShowAllFunctions || ShowFunction.empty()) { - if (OFormat == OutputFormat::Json) + if (OFormat == ShowFormat::Json) Reader->dumpJson(OS); else Reader->dump(OS); } else { - if (OFormat == OutputFormat::Json) + if (OFormat == ShowFormat::Json) exitWithError( "the JSON format is supported only when all functions are to " "be printed"); @@ -2679,8 +2679,8 @@ static int showMemProfProfile(const std::string &Filename, const std::string &ProfiledBinary, - OutputFormat OFormat, raw_fd_ostream &OS) { - if (OFormat == OutputFormat::Json) + ShowFormat OFormat, raw_fd_ostream &OS) { + if (OFormat == 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 showDebugInfoCorrelation(const std::string &Filename, bool ShowDetailedSummary, bool ShowProfileSymbolList, - OutputFormat OFormat, raw_fd_ostream &OS) { - if (OFormat == OutputFormat::Json) + ShowFormat OFormat, raw_fd_ostream &OS) { + if (OFormat == ShowFormat::Json) exitWithError("JSON output is not supported for debug info correlation"); std::unique_ptr Correlator; if (auto Err = InstrProfCorrelator::get(Filename).moveInto(Correlator)) exitWithError(std::move(Err), Filename); - if (OFormat == OutputFormat::Yaml) { + if (OFormat == ShowFormat::Yaml) { if (auto Err = Correlator->dumpYaml(OS)) exitWithError(std::move(Err), Filename); return 0; @@ -2737,17 +2737,20 @@ cl::opt ShowCounts("counts", cl::init(false), cl::desc("Show counter values for shown functions")); - cl::opt OFormat( - "output-format", cl::init(OutputFormat::None), + cl::opt OFormat( + "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 TextFormat( "text", cl::init(false), cl::desc("Show instr profile data in text dump format")); cl::opt 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 ShowIndirectCallTargets( "ic-targets", cl::init(false), cl::desc("Show indirect call site target values for shown functions")); @@ -2827,7 +2830,7 @@ return 1; } if (JsonFormat) - OFormat = OutputFormat::Json; + OFormat = ShowFormat::Json; std::error_code EC; raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_TextWithCRLF);