[llvm] [llvm-support][llvm-profdata] Use cl::Subcommand to organize show options. And look up in top-level as a fallback if a special subcommand doesn't have an option. (PR #71328)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 10:04:02 PST 2023


================
@@ -2448,101 +2449,14 @@ static void showValueSitesStats(raw_fd_ostream &OS, uint32_t VK,
   }
 }
 
-cl::opt<std::string> Filename(cl::Positional, cl::desc("<profdata-file>"));
-
-cl::opt<bool> ShowCounts("counts", cl::init(false),
-                         cl::desc("Show counter values for shown functions"));
-cl::opt<ShowFormat>
-    SFormat("show-format", cl::init(ShowFormat::Text),
-            cl::desc("Emit output in the selected format if supported"),
-            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 --show-format=json)"));
-cl::opt<bool> ShowIndirectCallTargets(
-    "ic-targets", cl::init(false),
-    cl::desc("Show indirect call site target values for shown functions"));
-cl::opt<bool> ShowMemOPSizes(
-    "memop-sizes", cl::init(false),
-    cl::desc("Show the profiled sizes of the memory intrinsic calls "
-             "for shown functions"));
-cl::opt<bool> ShowDetailedSummary("detailed-summary", cl::init(false),
-                                  cl::desc("Show detailed profile summary"));
-cl::list<uint32_t> DetailedSummaryCutoffs(
-    cl::CommaSeparated, "detailed-summary-cutoffs",
-    cl::desc(
-        "Cutoff percentages (times 10000) for generating detailed summary"),
-    cl::value_desc("800000,901000,999999"));
-cl::opt<bool> ShowHotFuncList(
-    "hot-func-list", cl::init(false),
-    cl::desc("Show profile summary of a list of hot functions"));
-cl::opt<bool> ShowAllFunctions("all-functions", cl::init(false),
-                               cl::desc("Details for every function"));
-cl::opt<bool> ShowCS("showcs", cl::init(false),
-                     cl::desc("Show context sensitive counts"));
-cl::opt<std::string> ShowFunction("function",
-                                  cl::desc("Details for matching functions"));
-
-cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
-                                    cl::init("-"), cl::desc("Output file"));
-cl::alias OutputFilenameA("o", cl::desc("Alias for --output"),
-                          cl::aliasopt(OutputFilename));
-cl::opt<ProfileKinds> ProfileKind(
-    cl::desc("Profile kind:"), cl::init(instr),
-    cl::values(clEnumVal(instr, "Instrumentation profile (default)"),
-               clEnumVal(sample, "Sample profile"),
-               clEnumVal(memory, "MemProf memory access profile")));
-cl::opt<uint32_t> TopNFunctions(
-    "topn", cl::init(0),
-    cl::desc("Show the list of functions with the largest internal counts"));
-cl::opt<uint32_t> ValueCutoff(
-    "value-cutoff", cl::init(0),
-    cl::desc("Set the count value cutoff. Functions with the maximum count "
-             "less than this value will not be printed out. (Default is 0)"));
-cl::opt<bool> OnlyListBelow(
-    "list-below-cutoff", cl::init(false),
-    cl::desc("Only output names of functions whose max count values are "
-             "below the cutoff value"));
-cl::opt<bool> ShowProfileSymbolList(
-    "show-prof-sym-list", cl::init(false),
-    cl::desc("Show profile symbol list if it exists in the profile. "));
-cl::opt<bool> ShowSectionInfoOnly(
-    "show-sec-info-only", cl::init(false),
-    cl::desc("Show the information of each section in the sample profile. "
-             "The flag is only usable when the sample profile is in "
-             "extbinary format"));
-cl::opt<bool> ShowBinaryIds("binary-ids", cl::init(false),
-                            cl::desc("Show binary ids in the profile. "));
-cl::opt<bool> ShowTemporalProfTraces(
-    "temporal-profile-traces",
-    cl::desc("Show temporal profile traces in the profile."));
-cl::opt<std::string> DebugInfoFilename(
-    "debug-info", cl::init(""),
-    cl::desc("Read and extract profile metadata from debug info and show "
-             "the functions it found."));
-cl::opt<unsigned> MaxDbgCorrelationWarnings(
-    "max-debug-info-correlation-warnings",
-    cl::desc("The maximum number of warnings to emit when correlating "
-             "profile from debug info (0 = no limit)"),
-    cl::init(5));
-cl::opt<bool>
-    ShowCovered("covered", cl::init(false),
-                cl::desc("Show only the functions that have been executed."));
-cl::opt<std::string> ProfiledBinary(
-    "profiled-binary", cl::init(""),
-    cl::desc("Path to binary from which the profile was collected."));
-cl::opt<bool> ShowProfileVersion("profile-version", cl::init(false),
-                                 cl::desc("Show profile version. "));
-
-static int showInstrProfile(const std::string &Filename, ShowFormat SFormat,
-                            raw_fd_ostream &OS) {
+static int showInstrProfile(
+    const std::string &Filename, bool ShowCounts, uint32_t TopN,
----------------
minglotus-6 wrote:

I updated {showInstrProfile, showSampleProfile, showMemProfProfile, showDebugInfoCorrelation} to use options directly.

https://github.com/llvm/llvm-project/pull/71328


More information about the llvm-commits mailing list