[clang] [compiler-rt] [llvm] Migrate llvm-profdata to Opt flag parsing (PR #177868)

David Zbarsky via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 5 08:15:36 PST 2026


https://github.com/dzbarsky updated https://github.com/llvm/llvm-project/pull/177868

>From d49e25b1d79ee86b0a97433b81acabc63f9c2ce1 Mon Sep 17 00:00:00 2001
From: David Zbarsky <dzbarsky at gmail.com>
Date: Sun, 25 Jan 2026 13:53:51 -0500
Subject: [PATCH 1/3] Migrate llvm-profdata to Opt flag parsing

---
 llvm/tools/llvm-profdata/CMakeLists.txt       |   11 +-
 llvm/tools/llvm-profdata/Opts.td              |  314 +++++
 llvm/tools/llvm-profdata/llvm-profdata.cpp    | 1092 ++++++++++-------
 .../llvm-project-overlay/llvm/BUILD.bazel     |   13 +-
 .../llvm-project-overlay/llvm/driver.bzl      |    1 +
 5 files changed, 952 insertions(+), 479 deletions(-)
 create mode 100644 llvm/tools/llvm-profdata/Opts.td

diff --git a/llvm/tools/llvm-profdata/CMakeLists.txt b/llvm/tools/llvm-profdata/CMakeLists.txt
index e5aa858f3d39c..6d64d48ef5db3 100644
--- a/llvm/tools/llvm-profdata/CMakeLists.txt
+++ b/llvm/tools/llvm-profdata/CMakeLists.txt
@@ -2,14 +2,23 @@ set(LLVM_LINK_COMPONENTS
   Core
   Object
   ProfileData
+  Option
   Support
   )
 
+set(LLVM_TARGET_DEFINITIONS Opts.td)
+tablegen(LLVM Opts.inc -gen-opt-parser-defs)
+add_public_tablegen_target(ProfdataOptsTableGen)
+
 add_llvm_tool(llvm-profdata
   llvm-profdata.cpp
 
   DEPENDS
   intrinsics_gen
+  ProfdataOptsTableGen
+  GENERATE_DRIVER
   )
 
-target_link_libraries(llvm-profdata PRIVATE LLVMDebuginfod)
+if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
+  target_link_libraries(llvm-profdata PRIVATE LLVMDebuginfod)
+endif()
diff --git a/llvm/tools/llvm-profdata/Opts.td b/llvm/tools/llvm-profdata/Opts.td
new file mode 100644
index 0000000000000..8803af9a10123
--- /dev/null
+++ b/llvm/tools/llvm-profdata/Opts.td
@@ -0,0 +1,314 @@
+include "llvm/Option/OptParser.td"
+
+def Show : SubCommand<"show",
+                      "Takes a profile data file and displays the profiles. "
+                      "See detailed documentation in "
+                      "https://llvm.org/docs/CommandGuide/llvm-profdata.html"
+                      "#profdata-show">;
+def Order : SubCommand<"order",
+                       "Reads temporal profiling traces from a profile and "
+                       "outputs a function order that reduces page faults. "
+                       "See detailed documentation in "
+                       "https://llvm.org/docs/CommandGuide/llvm-profdata.html"
+                       "#profdata-order">;
+def Overlap : SubCommand<"overlap",
+                         "Computes the overlap between two profiles. See "
+                         "detailed documentation in "
+                         "https://llvm.org/docs/CommandGuide/llvm-profdata.html"
+                         "#profdata-overlap">;
+def Merge : SubCommand<"merge",
+                       "Takes several profiles and merge them together. See "
+                       "detailed documentation in "
+                       "https://llvm.org/docs/CommandGuide/llvm-profdata.html"
+                       "#profdata-merge">;
+
+def help : Flag<["-","--"], "help", [Show, Order, Overlap, Merge]>,
+           HelpText<"Display this help">;
+def help_hidden : Flag<["--"], "help-hidden", [Show, Order, Overlap, Merge]>,
+                  HelpText<"Display all help, including hidden options">;
+def version : Flag<["--"], "version", [Show, Order, Overlap, Merge]>,
+              HelpText<"Display the version">;
+
+def output : JoinedOrSeparate<["-","--"], "output",
+                               [Show, Order, Overlap, Merge]>,
+             MetaVarName<"<output>">,
+             HelpText<"Output file">;
+def : JoinedOrSeparate<["-"], "o", [Show, Order, Overlap, Merge]>,
+     Alias<output>, HelpText<"Alias for --output">;
+
+def instr : Flag<["-","--"], "instr", [Show, Overlap, Merge]>,
+            HelpText<"Instrumentation profile (default)">;
+def sample : Flag<["-","--"], "sample", [Show, Overlap, Merge]>,
+             HelpText<"Sample profile">;
+def memory : Flag<["-","--"], "memory", [Show]>,
+             HelpText<"MemProf memory access profile">;
+
+def max_debug_info_correlation_warnings
+    : JoinedOrSeparate<["-","--"], "max-debug-info-correlation-warnings",
+                       [Show, Merge]>,
+      HelpText<"Maximum number of warnings to emit when correlating profile "
+               "from debug info (0 = no limit)">,
+      MetaVarName<"<n>">;
+def profiled_binary
+    : JoinedOrSeparate<["-","--"], "profiled-binary", [Show, Merge]>,
+      HelpText<"Path to binary from which the profile was collected.">,
+      MetaVarName<"<binary>">;
+def debug_info
+    : JoinedOrSeparate<["-","--"], "debug-info", [Show, Merge]>,
+      HelpText<"For show, read and extract profile metadata from debug info. "
+               "For merge, correlate the raw profile using the provided "
+               "debug info.">,
+      MetaVarName<"<file>">;
+def binary_file
+    : JoinedOrSeparate<["-","--"], "binary-file", [Merge]>,
+      HelpText<"Use the provided unstripped binary to correlate the raw "
+               "profile.">,
+      MetaVarName<"<file>">;
+def debug_file_directory
+    : JoinedOrSeparate<["-","--"], "debug-file-directory",
+                       [Show, Order, Overlap, Merge]>,
+      HelpText<"Directories to search for object files by build ID">,
+      MetaVarName<"<dir>">;
+def debuginfod : Flag<["-","--"], "debuginfod", [Merge]>,
+                 HelpText<"Enable debuginfod">, Flags<[HelpHidden]>;
+def correlate : JoinedOrSeparate<["-","--"], "correlate",
+                                  [Show, Order, Overlap, Merge]>,
+                HelpText<"Use debug-info or binary correlation to correlate "
+                         "profiles with build id fetcher">,
+                MetaVarName<"<mode>">;
+def function : JoinedOrSeparate<["-","--"], "function",
+                                [Show, Overlap, Merge]>,
+               HelpText<"Only functions matching the filter are shown or "
+                        "merged.">,
+               MetaVarName<"<regex>">;
+
+def weighted_input
+    : JoinedOrSeparate<["-","--"], "weighted-input", [Merge]>,
+      HelpText<"<weight>,<filename>">, MetaVarName<"<weight>,<file>">;
+def binary : Flag<["-","--"], "binary", [Merge]>,
+             HelpText<"Binary encoding">;
+def extbinary : Flag<["-","--"], "extbinary", [Merge]>,
+                HelpText<"Extensible binary encoding (default)">;
+def text : Flag<["-","--"], "text", [Show, Merge]>,
+           HelpText<"Text output format">;
+def gcc : Flag<["-","--"], "gcc", [Merge]>,
+          HelpText<"GCC encoding (only meaningful for -sample)">;
+def input_files
+    : JoinedOrSeparate<["-","--"], "input-files", [Merge]>,
+      HelpText<"Path to file containing newline-separated "
+               "[<weight>,]<filename> entries">,
+      MetaVarName<"<file>">;
+def : JoinedOrSeparate<["-"], "f", [Merge]>, Alias<input_files>,
+     HelpText<"Alias for --input-files">;
+def dump_input_file_list : Flag<["-","--"], "dump-input-file-list", [Merge]>,
+                           HelpText<"Dump the list of input files and their "
+                                    "weights, then exit">,
+                           Flags<[HelpHidden]>;
+def remapping_file
+    : JoinedOrSeparate<["-","--"], "remapping-file", [Merge]>,
+      HelpText<"Symbol remapping file">, MetaVarName<"<file>">;
+def : JoinedOrSeparate<["-"], "r", [Merge]>, Alias<remapping_file>,
+     HelpText<"Alias for --remapping-file">;
+def use_md5 : Flag<["-","--"], "use-md5", [Merge]>,
+              HelpText<"Use MD5 to represent strings in the name table "
+                       "(only meaningful for -extbinary)">,
+              Flags<[HelpHidden]>;
+def compress_all_sections
+    : Flag<["-","--"], "compress-all-sections", [Merge]>,
+      HelpText<"Compress all sections when writing the profile (only "
+               "meaningful for -extbinary)">,
+      Flags<[HelpHidden]>;
+def sample_merge_cold_context
+    : Flag<["-","--"], "sample-merge-cold-context", [Merge]>,
+      HelpText<"Merge context sample profiles whose count is below cold "
+               "threshold">,
+      Flags<[HelpHidden]>;
+def sample_trim_cold_context
+    : Flag<["-","--"], "sample-trim-cold-context", [Merge]>,
+      HelpText<"Trim context sample profiles whose count is below cold "
+               "threshold">,
+      Flags<[HelpHidden]>;
+def sample_frame_depth_for_cold_context
+    : JoinedOrSeparate<["-","--"], "sample-frame-depth-for-cold-context",
+                       [Merge]>,
+      HelpText<"Keep the last K frames while merging cold profile. 1 means "
+               "the context-less base profile">,
+      Flags<[HelpHidden]>, MetaVarName<"<depth>">;
+def output_size_limit
+    : JoinedOrSeparate<["-","--"], "output-size-limit", [Merge]>,
+      HelpText<"Trim cold functions until profile size is below specified "
+               "limit in bytes">,
+      Flags<[HelpHidden]>, MetaVarName<"<bytes>">;
+def gen_partial_profile
+    : Flag<["-","--"], "gen-partial-profile", [Merge]>,
+      HelpText<"Generate a partial profile (only meaningful for -extbinary)">,
+      Flags<[HelpHidden]>;
+def split_layout : Flag<["-","--"], "split-layout", [Merge]>,
+                   HelpText<"Split the profile into sections with and without "
+                            "inlined functions (only meaningful for "
+                            "-extbinary)">,
+                   Flags<[HelpHidden]>;
+def supplement_instr_with_sample
+    : JoinedOrSeparate<["-","--"], "supplement-instr-with-sample", [Merge]>,
+      HelpText<"Supplement an instr profile with a sample profile. Output "
+               "will be in instr format.">,
+      Flags<[HelpHidden]>, MetaVarName<"<sample-profile>">;
+def zero_counter_threshold
+    : JoinedOrSeparate<["-","--"], "zero-counter-threshold", [Merge]>,
+      HelpText<"Ratio of zero counters required to drop a function when "
+               "supplementing instr profiles">,
+      Flags<[HelpHidden]>, MetaVarName<"<ratio>">;
+def suppl_min_size_threshold
+    : JoinedOrSeparate<["-","--"], "suppl-min-size-threshold", [Merge]>,
+      HelpText<"Assume functions smaller than this threshold can be inlined "
+               "and will not be adjusted based on sample profile.">,
+      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+def instr_prof_cold_threshold
+    : JoinedOrSeparate<["-","--"], "instr-prof-cold-threshold", [Merge]>,
+      HelpText<"User specified cold threshold for instr profile to override "
+               "the cold threshold from profile summary.">,
+      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+def temporal_profile_trace_reservoir_size
+    : JoinedOrSeparate<["-","--"], "temporal-profile-trace-reservoir-size",
+                       [Merge]>,
+      HelpText<"Maximum number of stored temporal profile traces (default: "
+               "100)">,
+      MetaVarName<"<n>">;
+def temporal_profile_max_trace_length
+    : JoinedOrSeparate<["-","--"], "temporal-profile-max-trace-length",
+                       [Merge]>,
+      HelpText<"Maximum length of a single temporal profile trace "
+               "(default: 10000)">,
+      MetaVarName<"<n>">;
+def no_function : JoinedOrSeparate<["-","--"], "no-function", [Merge]>,
+                  HelpText<"Exclude functions matching the filter from the "
+                           "output.">,
+                  MetaVarName<"<regex>">;
+def failure_mode
+    : JoinedOrSeparate<["-","--"], "failure-mode", [Merge]>,
+      HelpText<"Failure mode: warn, any, or all">,
+      MetaVarName<"<mode>">;
+def sparse : Flag<["-","--"], "sparse", [Merge]>,
+             HelpText<"Generate a sparse profile (only meaningful for -instr)">;
+def num_threads : JoinedOrSeparate<["-","--"], "num-threads", [Merge]>,
+                  HelpText<"Number of merge threads to use (default: autodetect)">,
+                  MetaVarName<"<n>">;
+def : JoinedOrSeparate<["-"], "j", [Merge]>, Alias<num_threads>,
+     HelpText<"Alias for --num-threads">;
+def prof_sym_list
+    : JoinedOrSeparate<["-","--"], "prof-sym-list", [Merge]>,
+      HelpText<"Path to file containing the list of function symbols used to "
+               "populate profile symbol list">,
+      MetaVarName<"<file>">;
+def convert_sample_profile_layout
+    : JoinedOrSeparate<["-","--"], "convert-sample-profile-layout", [Merge]>,
+      HelpText<"Convert the generated profile to a new layout: nest or flat">,
+      MetaVarName<"<layout>">;
+def drop_profile_symbol_list
+    : Flag<["-","--"], "drop-profile-symbol-list", [Merge]>,
+      HelpText<"Drop the profile symbol list when merging AutoFDO profiles "
+               "(only meaningful for -sample)">,
+      Flags<[HelpHidden]>;
+def keep_vtable_symbols
+    : Flag<["-","--"], "keep-vtable-symbols", [Merge]>,
+      HelpText<"Keep the vtable symbols in indexed profiles">,
+      Flags<[HelpHidden]>;
+def write_prev_version
+    : Flag<["-","--"], "write-prev-version", [Merge]>,
+      HelpText<"Write the previous version of indexed format for forward "
+               "compatibility.">,
+      Flags<[HelpHidden]>;
+def memprof_version
+    : JoinedOrSeparate<["-","--"], "memprof-version", [Merge]>,
+      HelpText<"Specify the version of the memprof format to use (2, 3, or 4)">,
+      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+def memprof_full_schema
+    : Flag<["-","--"], "memprof-full-schema", [Merge]>,
+      HelpText<"Use the full schema for serialization">,
+      Flags<[HelpHidden]>;
+def memprof_random_hotness
+    : Flag<["-","--"], "memprof-random-hotness", [Merge]>,
+      HelpText<"Generate random hotness values">,
+      Flags<[HelpHidden]>;
+def memprof_random_hotness_seed
+    : JoinedOrSeparate<["-","--"], "memprof-random-hotness-seed", [Merge]>,
+      HelpText<"Random hotness seed to use (0 to generate new seed)">,
+      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+
+def similarity_cutoff
+    : JoinedOrSeparate<["-","--"], "similarity-cutoff", [Overlap]>,
+      HelpText<"List overlapped functions with similarities below the cutoff "
+               "(percentage times 10000).">,
+      MetaVarName<"<n>">;
+def cs : Flag<["-","--"], "cs", [Overlap]>,
+         HelpText<"For context sensitive PGO counts. Does not work with "
+                  "CSSPGO.">;
+def value_cutoff
+    : JoinedOrSeparate<["-","--"], "value-cutoff", [Show, Overlap]>,
+      HelpText<"Cutoff value used for filtering. Meaning depends on subcommand">,
+      MetaVarName<"<n>">;
+
+def counts : Flag<["-","--"], "counts", [Show]>,
+             HelpText<"Show counter values for shown functions">;
+def show_format
+    : JoinedOrSeparate<["-","--"], "show-format", [Show]>,
+      HelpText<"Emit output in the selected format: text, json, or yaml">,
+      MetaVarName<"<format>">;
+def json : Flag<["-","--"], "json", [Show]>,
+           HelpText<"Show sample profile data in JSON format "
+                    "(deprecated, use --show-format=json)">;
+def ic_targets : Flag<["-","--"], "ic-targets", [Show]>,
+                 HelpText<"Show indirect call site target values">;
+def show_vtables : Flag<["-","--"], "show-vtables", [Show]>,
+                   HelpText<"Show vtable names for shown functions">;
+def memop_sizes : Flag<["-","--"], "memop-sizes", [Show]>,
+                  HelpText<"Show profiled sizes of memory intrinsic calls">;
+def detailed_summary : Flag<["-","--"], "detailed-summary", [Show]>,
+                       HelpText<"Show detailed profile summary">;
+def detailed_summary_cutoffs
+    : CommaJoined<["-","--"], "detailed-summary-cutoffs", [Show]>,
+      HelpText<"Cutoff percentages (times 10000) for generating detailed "
+               "summary">,
+      MetaVarName<"<list>">;
+def hot_func_list : Flag<["-","--"], "hot-func-list", [Show]>,
+                    HelpText<"Show profile summary of a list of hot functions">;
+def all_functions : Flag<["-","--"], "all-functions", [Show]>,
+                    HelpText<"Details for each and every function">;
+def showcs : Flag<["-","--"], "showcs", [Show]>,
+             HelpText<"Show context sensitive counts">;
+def topn : JoinedOrSeparate<["-","--"], "topn", [Show]>,
+           HelpText<"Show the list of functions with the largest internal counts">,
+           MetaVarName<"<n>">;
+def list_below_cutoff
+    : Flag<["-","--"], "list-below-cutoff", [Show]>,
+      HelpText<"Only output names of functions whose max count values are "
+               "below the cutoff value">;
+def show_prof_sym_list
+    : Flag<["-","--"], "show-prof-sym-list", [Show]>,
+      HelpText<"Show profile symbol list if it exists in the profile.">;
+def show_sec_info_only
+    : Flag<["-","--"], "show-sec-info-only", [Show]>,
+      HelpText<"Show the information of each section in the sample profile "
+               "(extbinary sample profiles only)">;
+def binary_ids : Flag<["-","--"], "binary-ids", [Show]>,
+                 HelpText<"Show binary ids in the profile.">;
+def temporal_profile_traces
+    : Flag<["-","--"], "temporal-profile-traces", [Show]>,
+      HelpText<"Show temporal profile traces in the profile.">;
+def covered : Flag<["-","--"], "covered", [Show]>,
+              HelpText<"Show only the functions that have been executed.">;
+def profile_version : Flag<["-","--"], "profile-version", [Show]>,
+                      HelpText<"Show profile version.">;
+
+def num_test_traces
+    : JoinedOrSeparate<["-","--"], "num-test-traces", [Order]>,
+      HelpText<"Keep aside the last <num-test-traces> traces when computing "
+               "function order to evaluate that order">,
+      MetaVarName<"<n>">;
+
+def fs_discriminator_pass
+    : JoinedOrSeparate<["-","--"], "fs-discriminator-pass",
+                       [Show, Overlap, Merge]>,
+      HelpText<"Zero out the discriminator bits for the FS discriminator "
+               "pass beyond this value.">,
+      Flags<[HelpHidden]>, MetaVarName<"<pass>">;
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 74c4732ca129a..4c8c7519df9ca 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -10,13 +10,20 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/Object/Binary.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
 #include "llvm/ProfileData/DataAccessProf.h"
 #include "llvm/ProfileData/InstrProfCorrelator.h"
 #include "llvm/ProfileData/InstrProfReader.h"
@@ -35,11 +42,12 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/StringSaver.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -47,35 +55,15 @@
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cmath>
+#include <limits>
 #include <optional>
 
+#include "Opts.inc"
+
 using namespace llvm;
+using namespace llvm::opt;
 using ProfCorrelatorKind = InstrProfCorrelator::ProfCorrelatorKind;
 
-// https://llvm.org/docs/CommandGuide/llvm-profdata.html has documentations
-// on each subcommand.
-cl::SubCommand ShowSubcommand(
-    "show",
-    "Takes a profile data file and displays the profiles. See detailed "
-    "documentation in "
-    "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-show");
-cl::SubCommand OrderSubcommand(
-    "order",
-    "Reads temporal profiling traces from a profile and outputs a function "
-    "order that reduces the number of page faults for those traces. See "
-    "detailed documentation in "
-    "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-order");
-cl::SubCommand OverlapSubcommand(
-    "overlap",
-    "Computes and displays the overlap between two profiles. See detailed "
-    "documentation in "
-    "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-overlap");
-cl::SubCommand MergeSubcommand(
-    "merge",
-    "Takes several profiles and merge them together. See detailed "
-    "documentation in "
-    "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-merge");
-
 namespace {
 enum ProfileKinds { instr, sample, memory };
 enum FailureMode { warnOnly, failIfAnyAreInvalid, failIfAllAreInvalid };
@@ -90,408 +78,132 @@ enum ProfileFormat {
 };
 
 enum class ShowFormat { Text, Json, Yaml };
-} // namespace
 
-// Common options.
-cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
-                                    cl::init("-"), cl::desc("Output file"),
-                                    cl::sub(ShowSubcommand),
-                                    cl::sub(OrderSubcommand),
-                                    cl::sub(OverlapSubcommand),
-                                    cl::sub(MergeSubcommand));
-// NOTE: cl::alias must not have cl::sub(), since aliased option's cl::sub()
-// will be used. llvm::cl::alias::done() method asserts this condition.
-static cl::alias OutputFilenameA("o", cl::desc("Alias for --output"),
-                                 cl::aliasopt(OutputFilename));
-
-// Options common to at least two commands.
-static cl::opt<ProfileKinds> ProfileKind(
-    cl::desc("Profile kind:"), cl::sub(MergeSubcommand),
-    cl::sub(OverlapSubcommand), cl::init(instr),
-    cl::values(clEnumVal(instr, "Instrumentation profile (default)"),
-               clEnumVal(sample, "Sample profile")));
-static cl::opt<std::string> Filename(cl::Positional,
-                                     cl::desc("<profdata-file>"),
-                                     cl::sub(ShowSubcommand),
-                                     cl::sub(OrderSubcommand));
-static 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::sub(MergeSubcommand), cl::sub(ShowSubcommand), cl::init(5));
-static cl::opt<std::string> ProfiledBinary(
-    "profiled-binary", cl::init(""),
-    cl::desc("Path to binary from which the profile was collected."),
-    cl::sub(ShowSubcommand), cl::sub(MergeSubcommand));
-static cl::opt<std::string> DebugInfoFilename(
-    "debug-info", cl::init(""),
-    cl::desc(
-        "For show, read and extract profile metadata from debug info and show "
-        "the functions it found. For merge, use the provided debug info to "
-        "correlate the raw profile."),
-    cl::sub(ShowSubcommand), cl::sub(MergeSubcommand));
-static cl::opt<std::string>
-    BinaryFilename("binary-file", cl::init(""),
-                   cl::desc("For merge, use the provided unstripped binary to "
-                            "correlate the raw profile."),
-                   cl::sub(MergeSubcommand));
-static cl::list<std::string> DebugFileDirectory(
-    "debug-file-directory",
-    cl::desc("Directories to search for object files by build ID"));
-static cl::opt<bool> DebugInfod("debuginfod", cl::init(false), cl::Hidden,
-                                cl::sub(MergeSubcommand),
-                                cl::desc("Enable debuginfod"));
-static cl::opt<ProfCorrelatorKind> BIDFetcherProfileCorrelate(
-    "correlate",
-    cl::desc("Use debug-info or binary correlation to correlate profiles with "
-             "build id fetcher"),
-    cl::init(InstrProfCorrelator::NONE),
-    cl::values(clEnumValN(InstrProfCorrelator::NONE, "",
-                          "No profile correlation"),
-               clEnumValN(InstrProfCorrelator::DEBUG_INFO, "debug-info",
-                          "Use debug info to correlate"),
-               clEnumValN(InstrProfCorrelator::BINARY, "binary",
-                          "Use binary to correlate")));
-static cl::opt<std::string> FuncNameFilter(
-    "function",
-    cl::desc("Only functions matching the filter are shown in the output. For "
-             "overlapping CSSPGO, this takes a function name with calling "
-             "context."),
-    cl::sub(ShowSubcommand), cl::sub(OverlapSubcommand),
-    cl::sub(MergeSubcommand));
-
-// TODO: Consider creating a template class (e.g., MergeOption, ShowOption) to
-// factor out the common cl::sub in cl::opt constructor for subcommand-specific
-// options.
-
-// Options specific to merge subcommand.
-static cl::list<std::string> InputFilenames(cl::Positional,
-                                            cl::sub(MergeSubcommand),
-                                            cl::desc("<filename...>"));
-static cl::list<std::string>
-    WeightedInputFilenames("weighted-input", cl::sub(MergeSubcommand),
-                           cl::desc("<weight>,<filename>"));
-static cl::opt<ProfileFormat> OutputFormat(
-    cl::desc("Format of output profile"), cl::sub(MergeSubcommand),
-    cl::init(PF_Ext_Binary),
-    cl::values(clEnumValN(PF_Binary, "binary", "Binary encoding"),
-               clEnumValN(PF_Ext_Binary, "extbinary",
-                          "Extensible binary encoding "
-                          "(default)"),
-               clEnumValN(PF_Text, "text", "Text encoding"),
-               clEnumValN(PF_GCC, "gcc",
-                          "GCC encoding (only meaningful for -sample)")));
-static cl::opt<std::string>
-    InputFilenamesFile("input-files", cl::init(""), cl::sub(MergeSubcommand),
-                       cl::desc("Path to file containing newline-separated "
-                                "[<weight>,]<filename> entries"));
-static cl::alias InputFilenamesFileA("f", cl::desc("Alias for --input-files"),
-                                     cl::aliasopt(InputFilenamesFile));
-static cl::opt<bool> DumpInputFileList(
-    "dump-input-file-list", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Dump the list of input files and their weights, then exit"));
-static cl::opt<std::string> RemappingFile("remapping-file",
-                                          cl::value_desc("file"),
-                                          cl::sub(MergeSubcommand),
-                                          cl::desc("Symbol remapping file"));
-static cl::alias RemappingFileA("r", cl::desc("Alias for --remapping-file"),
-                                cl::aliasopt(RemappingFile));
-static cl::opt<bool>
-    UseMD5("use-md5", cl::init(false), cl::Hidden,
-           cl::desc("Choose to use MD5 to represent string in name table (only "
-                    "meaningful for -extbinary)"),
-           cl::sub(MergeSubcommand));
-static cl::opt<bool> CompressAllSections(
-    "compress-all-sections", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Compress all sections when writing the profile (only "
-             "meaningful for -extbinary)"));
-static cl::opt<bool> SampleMergeColdContext(
-    "sample-merge-cold-context", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc(
-        "Merge context sample profiles whose count is below cold threshold"));
-static cl::opt<bool> SampleTrimColdContext(
-    "sample-trim-cold-context", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc(
-        "Trim context sample profiles whose count is below cold threshold"));
-static cl::opt<uint32_t> SampleColdContextFrameDepth(
-    "sample-frame-depth-for-cold-context", cl::init(1),
-    cl::sub(MergeSubcommand),
-    cl::desc("Keep the last K frames while merging cold profile. 1 means the "
-             "context-less base profile"));
-static cl::opt<size_t> OutputSizeLimit(
-    "output-size-limit", cl::init(0), cl::Hidden, cl::sub(MergeSubcommand),
-    cl::desc("Trim cold functions until profile size is below specified "
-             "limit in bytes. This uses a heursitic and functions may be "
-             "excessively trimmed"));
-static cl::opt<bool> GenPartialProfile(
-    "gen-partial-profile", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Generate a partial profile (only meaningful for -extbinary)"));
-static cl::opt<bool> SplitLayout(
-    "split-layout", cl::init(false), cl::Hidden, cl::sub(MergeSubcommand),
-    cl::desc("Split the profile to two sections with one containing sample "
-             "profiles with inlined functions and the other without (only "
-             "meaningful for -extbinary)"));
-static cl::opt<std::string> SupplInstrWithSample(
-    "supplement-instr-with-sample", cl::init(""), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Supplement an instr profile with sample profile, to correct "
-             "the profile unrepresentativeness issue. The sample "
-             "profile is the input of the flag. Output will be in instr "
-             "format (The flag only works with -instr)"));
-static cl::opt<float> ZeroCounterThreshold(
-    "zero-counter-threshold", cl::init(0.7), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("For the function which is cold in instr profile but hot in "
-             "sample profile, if the ratio of the number of zero counters "
-             "divided by the total number of counters is above the "
-             "threshold, the profile of the function will be regarded as "
-             "being harmful for performance and will be dropped."));
-static cl::opt<unsigned> SupplMinSizeThreshold(
-    "suppl-min-size-threshold", cl::init(10), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("If the size of a function is smaller than the threshold, "
-             "assume it can be inlined by PGO early inliner and it won't "
-             "be adjusted based on sample profile."));
-static cl::opt<unsigned> InstrProfColdThreshold(
-    "instr-prof-cold-threshold", cl::init(0), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("User specified cold threshold for instr profile which will "
-             "override the cold threshold got from profile summary. "));
-// WARNING: This reservoir size value is propagated to any input indexed
-// profiles for simplicity. Changing this value between invocations could
-// result in sample bias.
-static cl::opt<uint64_t> TemporalProfTraceReservoirSize(
-    "temporal-profile-trace-reservoir-size", cl::init(100),
-    cl::sub(MergeSubcommand),
-    cl::desc("The maximum number of stored temporal profile traces (default: "
-             "100)"));
-static cl::opt<uint64_t> TemporalProfMaxTraceLength(
-    "temporal-profile-max-trace-length", cl::init(10000),
-    cl::sub(MergeSubcommand),
-    cl::desc("The maximum length of a single temporal profile trace "
-             "(default: 10000)"));
-static cl::opt<std::string> FuncNameNegativeFilter(
-    "no-function", cl::init(""), cl::sub(MergeSubcommand),
-    cl::desc("Exclude functions matching the filter from the output."));
-
-static cl::opt<FailureMode>
-    FailMode("failure-mode", cl::init(failIfAnyAreInvalid),
-             cl::desc("Failure mode:"), cl::sub(MergeSubcommand),
-             cl::values(clEnumValN(warnOnly, "warn",
-                                   "Do not fail and just print warnings."),
-                        clEnumValN(failIfAnyAreInvalid, "any",
-                                   "Fail if any profile is invalid."),
-                        clEnumValN(failIfAllAreInvalid, "all",
-                                   "Fail only if all profiles are invalid.")));
-
-static cl::opt<bool> OutputSparse(
-    "sparse", cl::init(false), cl::sub(MergeSubcommand),
-    cl::desc("Generate a sparse profile (only meaningful for -instr)"));
-static cl::opt<unsigned> NumThreads(
-    "num-threads", cl::init(0), cl::sub(MergeSubcommand),
-    cl::desc("Number of merge threads to use (default: autodetect)"));
-static cl::alias NumThreadsA("j", cl::desc("Alias for --num-threads"),
-                             cl::aliasopt(NumThreads));
-
-static cl::opt<std::string> ProfileSymbolListFile(
-    "prof-sym-list", cl::init(""), cl::sub(MergeSubcommand),
-    cl::desc("Path to file containing the list of function symbols "
-             "used to populate profile symbol list"));
-
-static cl::opt<SampleProfileLayout> ProfileLayout(
-    "convert-sample-profile-layout",
-    cl::desc("Convert the generated profile to a profile with a new layout"),
-    cl::sub(MergeSubcommand), cl::init(SPL_None),
-    cl::values(
-        clEnumValN(SPL_Nest, "nest",
-                   "Nested profile, the input should be CS flat profile"),
-        clEnumValN(SPL_Flat, "flat",
-                   "Profile with nested inlinee flatten out")));
-
-static cl::opt<bool> DropProfileSymbolList(
-    "drop-profile-symbol-list", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Drop the profile symbol list when merging AutoFDO profiles "
-             "(only meaningful for -sample)"));
-
-static cl::opt<bool> KeepVTableSymbols(
-    "keep-vtable-symbols", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("If true, keep the vtable symbols in indexed profiles"));
-
-// Temporary support for writing the previous version of the format, to enable
-// some forward compatibility.
-// TODO: Consider enabling this with future version changes as well, to ease
-// deployment of newer versions of llvm-profdata.
-static cl::opt<bool> DoWritePrevVersion(
-    "write-prev-version", cl::init(false), cl::Hidden,
-    cl::desc("Write the previous version of indexed format, to enable "
-             "some forward compatibility."));
-
-static cl::opt<memprof::IndexedVersion> MemProfVersionRequested(
-    "memprof-version", cl::Hidden, cl::sub(MergeSubcommand),
-    cl::desc("Specify the version of the memprof format to use"),
-    cl::init(memprof::Version3),
-    cl::values(clEnumValN(memprof::Version2, "2", "version 2"),
-               clEnumValN(memprof::Version3, "3", "version 3"),
-               clEnumValN(memprof::Version4, "4", "version 4")));
-
-static cl::opt<bool> MemProfFullSchema(
-    "memprof-full-schema", cl::Hidden, cl::sub(MergeSubcommand),
-    cl::desc("Use the full schema for serialization"), cl::init(false));
-
-static cl::opt<bool>
-    MemprofGenerateRandomHotness("memprof-random-hotness", cl::init(false),
-                                 cl::Hidden, cl::sub(MergeSubcommand),
-                                 cl::desc("Generate random hotness values"));
-static cl::opt<unsigned> MemprofGenerateRandomHotnessSeed(
-    "memprof-random-hotness-seed", cl::init(0), cl::Hidden,
-    cl::sub(MergeSubcommand),
-    cl::desc("Random hotness seed to use (0 to generate new seed)"));
-
-// Options specific to overlap subcommand.
-static cl::opt<std::string> BaseFilename(cl::Positional, cl::Required,
-                                         cl::desc("<base profile file>"),
-                                         cl::sub(OverlapSubcommand));
-static cl::opt<std::string> TestFilename(cl::Positional, cl::Required,
-                                         cl::desc("<test profile file>"),
-                                         cl::sub(OverlapSubcommand));
-
-static cl::opt<unsigned long long> SimilarityCutoff(
-    "similarity-cutoff", cl::init(0),
-    cl::desc("For sample profiles, list function names (with calling context "
-             "for csspgo) for overlapped functions "
-             "with similarities below the cutoff (percentage times 10000)."),
-    cl::sub(OverlapSubcommand));
-
-static cl::opt<bool> IsCS(
-    "cs", cl::init(false),
-    cl::desc("For context sensitive PGO counts. Does not work with CSSPGO."),
-    cl::sub(OverlapSubcommand));
-
-static cl::opt<unsigned long long> OverlapValueCutoff(
-    "value-cutoff", cl::init(-1),
-    cl::desc(
-        "Function level overlap information for every function (with calling "
-        "context for csspgo) in test "
-        "profile with max count value greater than the parameter value"),
-    cl::sub(OverlapSubcommand));
-
-// Options specific to show subcommand.
-static cl::opt<bool>
-    ShowCounts("counts", cl::init(false),
-               cl::desc("Show counter values for shown functions"),
-               cl::sub(ShowSubcommand));
-static cl::opt<ShowFormat>
-    SFormat("show-format", cl::init(ShowFormat::Text),
-            cl::desc("Emit output in the selected format if supported"),
-            cl::sub(ShowSubcommand),
-            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`.
-static cl::opt<bool>
-    TextFormat("text", cl::init(false),
-               cl::desc("Show instr profile data in text dump format"),
-               cl::sub(ShowSubcommand));
-static cl::opt<bool>
-    JsonFormat("json",
-               cl::desc("Show sample profile data in the JSON format "
-                        "(deprecated, please use --show-format=json)"),
-               cl::sub(ShowSubcommand));
-static cl::opt<bool> ShowIndirectCallTargets(
-    "ic-targets", cl::init(false),
-    cl::desc("Show indirect call site target values for shown functions"),
-    cl::sub(ShowSubcommand));
-static cl::opt<bool>
-    ShowVTables("show-vtables", cl::init(false),
-                cl::desc("Show vtable names for shown functions"),
-                cl::sub(ShowSubcommand));
-static cl::opt<bool> ShowMemOPSizes(
-    "memop-sizes", cl::init(false),
-    cl::desc("Show the profiled sizes of the memory intrinsic calls "
-             "for shown functions"),
-    cl::sub(ShowSubcommand));
-static cl::opt<bool>
-    ShowDetailedSummary("detailed-summary", cl::init(false),
-                        cl::desc("Show detailed profile summary"),
-                        cl::sub(ShowSubcommand));
-static 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::sub(ShowSubcommand));
-static cl::opt<bool>
-    ShowHotFuncList("hot-func-list", cl::init(false),
-                    cl::desc("Show profile summary of a list of hot functions"),
-                    cl::sub(ShowSubcommand));
-static cl::opt<bool>
-    ShowAllFunctions("all-functions", cl::init(false),
-                     cl::desc("Details for each and every function"),
-                     cl::sub(ShowSubcommand));
-static cl::opt<bool> ShowCS("showcs", cl::init(false),
-                            cl::desc("Show context sensitive counts"),
-                            cl::sub(ShowSubcommand));
-static cl::opt<ProfileKinds> ShowProfileKind(
-    cl::desc("Profile kind supported by show:"), cl::sub(ShowSubcommand),
-    cl::init(instr),
-    cl::values(clEnumVal(instr, "Instrumentation profile (default)"),
-               clEnumVal(sample, "Sample profile"),
-               clEnumVal(memory, "MemProf memory access profile")));
-static cl::opt<uint32_t> TopNFunctions(
-    "topn", cl::init(0),
-    cl::desc("Show the list of functions with the largest internal counts"),
-    cl::sub(ShowSubcommand));
-static cl::opt<uint32_t> ShowValueCutoff(
-    "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::sub(ShowSubcommand));
-static 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::sub(ShowSubcommand));
-static cl::opt<bool> ShowProfileSymbolList(
-    "show-prof-sym-list", cl::init(false),
-    cl::desc("Show profile symbol list if it exists in the profile. "),
-    cl::sub(ShowSubcommand));
-static 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::sub(ShowSubcommand));
-static cl::opt<bool> ShowBinaryIds("binary-ids", cl::init(false),
-                                   cl::desc("Show binary ids in the profile. "),
-                                   cl::sub(ShowSubcommand));
-static cl::opt<bool> ShowTemporalProfTraces(
-    "temporal-profile-traces",
-    cl::desc("Show temporal profile traces in the profile."),
-    cl::sub(ShowSubcommand));
-
-static cl::opt<bool>
-    ShowCovered("covered", cl::init(false),
-                cl::desc("Show only the functions that have been executed."),
-                cl::sub(ShowSubcommand));
-
-static cl::opt<bool> ShowProfileVersion("profile-version", cl::init(false),
-                                        cl::desc("Show profile version. "),
-                                        cl::sub(ShowSubcommand));
-
-// Options specific to order subcommand.
-static cl::opt<unsigned>
-    NumTestTraces("num-test-traces", cl::init(0),
-                  cl::desc("Keep aside the last <num-test-traces> traces in "
-                           "the profile when computing the function order and "
-                           "instead use them to evaluate that order"),
-                  cl::sub(OrderSubcommand));
+enum ID {
+  OPT_INVALID = 0,
+#define OPTION(PREFIXES, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS,       \
+               VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR,     \
+               VALUES, SUBCOMMANDIDS_OFFSET)                                   \
+  OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
+};
+
+#define OPTTABLE_STR_TABLE_CODE
+#include "Opts.inc"
+#undef OPTTABLE_STR_TABLE_CODE
+
+#define OPTTABLE_PREFIXES_TABLE_CODE
+#include "Opts.inc"
+#undef OPTTABLE_PREFIXES_TABLE_CODE
+
+#define OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE
+#include "Opts.inc"
+#undef OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE
+
+#define OPTTABLE_SUBCOMMANDS_CODE
+#include "Opts.inc"
+#undef OPTTABLE_SUBCOMMANDS_CODE
+
+static constexpr opt::OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "Opts.inc"
+#undef OPTION
+};
+
+class ProfdataOptTable : public opt::GenericOptTable {
+public:
+  ProfdataOptTable()
+      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable,
+                             /*IgnoreCase=*/false, OptionSubCommands,
+                             OptionSubCommandIDsTable) {
+    setGroupedShortOptions(true);
+    setDashDashParsing(true);
+  }
+};
+
+static std::string ProgramName;
+
+static std::string OutputFilename = "-";
+static ProfileKinds ProfileKind = instr;
+static std::string Filename;
+static unsigned MaxDbgCorrelationWarnings = 5;
+static std::string ProfiledBinary;
+static std::string DebugInfoFilename;
+static std::string BinaryFilename;
+static std::vector<std::string> DebugFileDirectory;
+static bool DebugInfod = false;
+static ProfCorrelatorKind BIDFetcherProfileCorrelate =
+    InstrProfCorrelator::NONE;
+static std::string FuncNameFilter;
+
+static std::vector<std::string> InputFilenames;
+static std::vector<std::string> WeightedInputFilenames;
+static ProfileFormat OutputFormat = PF_Ext_Binary;
+static std::string InputFilenamesFile;
+static bool DumpInputFileList = false;
+static std::string RemappingFile;
+static bool UseMD5 = false;
+static bool CompressAllSections = false;
+static bool SampleMergeColdContext = false;
+static bool SampleTrimColdContext = false;
+static uint32_t SampleColdContextFrameDepth = 1;
+static size_t OutputSizeLimit = 0;
+static bool GenPartialProfile = false;
+static bool SplitLayout = false;
+static std::string SupplInstrWithSample;
+static float ZeroCounterThreshold = 0.7f;
+static unsigned SupplMinSizeThreshold = 10;
+static unsigned InstrProfColdThreshold = 0;
+static uint64_t TemporalProfTraceReservoirSize = 100;
+static uint64_t TemporalProfMaxTraceLength = 10000;
+static std::string FuncNameNegativeFilter;
+static FailureMode FailMode = failIfAnyAreInvalid;
+static bool OutputSparse = false;
+static unsigned NumThreads = 0;
+static std::string ProfileSymbolListFile;
+static SampleProfileLayout ProfileLayout = SPL_None;
+static bool DropProfileSymbolList = false;
+static bool KeepVTableSymbols = false;
+static bool DoWritePrevVersion = false;
+static memprof::IndexedVersion MemProfVersionRequested = memprof::Version3;
+static bool MemProfFullSchema = false;
+static bool MemprofGenerateRandomHotness = false;
+static unsigned MemprofGenerateRandomHotnessSeed = 0;
+
+static std::string BaseFilename;
+static std::string TestFilename;
+static unsigned long long SimilarityCutoff = 0;
+static bool IsCS = false;
+static unsigned long long OverlapValueCutoff =
+    std::numeric_limits<unsigned long long>::max();
+
+static bool ShowCounts = false;
+static ShowFormat SFormat = ShowFormat::Text;
+static bool TextFormat = false;
+static bool JsonFormat = false;
+static bool ShowIndirectCallTargets = false;
+static bool ShowVTables = false;
+static bool ShowMemOPSizes = false;
+static bool ShowDetailedSummary = false;
+static std::vector<uint32_t> DetailedSummaryCutoffs;
+static bool ShowHotFuncList = false;
+static bool ShowAllFunctions = false;
+static bool ShowCS = false;
+static ProfileKinds ShowProfileKind = instr;
+static uint32_t TopNFunctions = 0;
+static uint32_t ShowValueCutoff = 0;
+static bool OnlyListBelow = false;
+static bool ShowProfileSymbolList = false;
+static bool ShowSectionInfoOnly = false;
+static bool ShowBinaryIds = false;
+static bool ShowTemporalProfTraces = false;
+static bool ShowCovered = false;
+static bool ShowProfileVersion = false;
+
+static unsigned NumTestTraces = 0;
+static FSDiscriminatorPass FSDiscriminatorPassOption = PassLast;
+} // namespace
 
 // We use this string to indicate that there are
 // multiple static functions map to the same name.
@@ -637,7 +349,7 @@ class SymbolRemapper {
     return New.empty() ? Name : FunctionId(New);
   }
 };
-}
+} // namespace
 
 struct WeightedFile {
   std::string Filename;
@@ -897,13 +609,11 @@ getFuncName(const StringMap<InstrProfWriter::ProfilingData>::value_type &Val) {
   return Val.first();
 }
 
-static std::string
-getFuncName(const SampleProfileMap::value_type &Val) {
+static std::string getFuncName(const SampleProfileMap::value_type &Val) {
   return Val.second.getContext().toString();
 }
 
-template <typename T>
-static void filterFunctions(T &ProfileMap) {
+template <typename T> static void filterFunctions(T &ProfileMap) {
   bool hasFilter = !FuncNameFilter.empty();
   bool hasNegativeFilter = !FuncNameNegativeFilter.empty();
   if (!hasFilter && !hasNegativeFilter)
@@ -973,8 +683,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs,
                               SymbolRemapper *Remapper,
                               int MaxDbgCorrelationWarnings,
                               const StringRef ProfiledBinary) {
-  const uint64_t TraceReservoirSize = TemporalProfTraceReservoirSize.getValue();
-  const uint64_t MaxTraceLength = TemporalProfMaxTraceLength.getValue();
+  const uint64_t TraceReservoirSize = TemporalProfTraceReservoirSize;
+  const uint64_t MaxTraceLength = TemporalProfMaxTraceLength;
   if (OutputFormat == PF_Compact_Binary)
     exitWithError("Compact Binary is deprecated");
   if (OutputFormat != PF_Binary && OutputFormat != PF_Ext_Binary &&
@@ -1171,21 +881,8 @@ const uint64_t HotPercentileIdx = 11;
 
 using sampleprof::FSDiscriminatorPass;
 
-// Internal options to set FSDiscriminatorPass. Used in merge and show
-// commands.
-static cl::opt<FSDiscriminatorPass> FSDiscriminatorPassOption(
-    "fs-discriminator-pass", cl::init(PassLast), cl::Hidden,
-    cl::desc("Zero out the discriminator bits for the FS discrimiantor "
-             "pass beyond this value. The enum values are defined in "
-             "Support/Discriminator.h"),
-    cl::values(clEnumVal(Base, "Use base discriminators only"),
-               clEnumVal(Pass1, "Use base and pass 1 discriminators"),
-               clEnumVal(Pass2, "Use base and pass 1-2 discriminators"),
-               clEnumVal(Pass3, "Use base and pass 1-3 discriminators"),
-               clEnumVal(PassLast, "Use all discriminator bits (default)")));
-
 static unsigned getDiscriminatorMask() {
-  return getN1Bits(getFSPassBitEnd(FSDiscriminatorPassOption.getValue()));
+  return getN1Bits(getFSPassBitEnd(FSDiscriminatorPassOption));
 }
 
 /// Adjust the instr profile in \p WC based on the sample profile in
@@ -1504,8 +1201,8 @@ remapSamples(const sampleprof::FunctionSamples &Samples,
                           BodySample.second.getSamples());
     for (const auto &Target : BodySample.second.getCallTargets()) {
       Result.addCalledTargetSamples(BodySample.first.LineOffset,
-                                    MaskedDiscriminator,
-                                    Remapper(Target.first), Target.second);
+                                    MaskedDiscriminator, Remapper(Target.first),
+                                    Target.second);
     }
   }
   for (const auto &CallsiteSamples : Samples.getCallsiteSamples()) {
@@ -1522,12 +1219,8 @@ remapSamples(const sampleprof::FunctionSamples &Samples,
 }
 
 static sampleprof::SampleProfileFormat FormatMap[] = {
-    sampleprof::SPF_None,
-    sampleprof::SPF_Text,
-    sampleprof::SPF_None,
-    sampleprof::SPF_Ext_Binary,
-    sampleprof::SPF_GCC,
-    sampleprof::SPF_Binary};
+    sampleprof::SPF_None,       sampleprof::SPF_Text, sampleprof::SPF_None,
+    sampleprof::SPF_Ext_Binary, sampleprof::SPF_GCC,  sampleprof::SPF_Binary};
 
 static std::unique_ptr<MemoryBuffer>
 getInputFileBuf(const StringRef &InputFile) {
@@ -3375,9 +3068,8 @@ static int showDebugInfoCorrelation(const std::string &Filename,
 
 static int show_main(StringRef ProgName) {
   if (Filename.empty() && DebugInfoFilename.empty())
-    exitWithError(
-        "the positional argument '<profdata-file>' is required unless '--" +
-        DebugInfoFilename.ArgStr + "' is provided");
+    exitWithError("the positional argument '<profdata-file>' is required "
+                  "unless '--debug-info' is provided");
 
   if (Filename == OutputFilename) {
     errs() << ProgName
@@ -3394,7 +3086,8 @@ static int show_main(StringRef ProgName) {
     exitWithErrorCode(EC, OutputFilename);
 
   if (ShowAllFunctions && !FuncNameFilter.empty())
-    WithColor::warning() << "-function argument ignored: showing all functions\n";
+    WithColor::warning()
+        << "-function argument ignored: showing all functions\n";
 
   if (!DebugInfoFilename.empty())
     return showDebugInfoCorrelation(DebugInfoFilename, SFormat, OS);
@@ -3424,7 +3117,7 @@ static int order_main() {
   ArrayRef Traces = Reader->getTemporalProfTraces();
   if (NumTestTraces && NumTestTraces >= Traces.size())
     exitWithError(
-        "--" + NumTestTraces.ArgStr +
+        "--num-test-traces"
         " must be smaller than the total number of traces: expected: < " +
         Twine(Traces.size()) + ", actual: " + Twine(NumTestTraces));
   ArrayRef TestTraces = Traces.take_back(NumTestTraces);
@@ -3471,32 +3164,477 @@ static int order_main() {
   return 0;
 }
 
-int main(int argc, const char *argv[]) {
-  InitLLVM X(argc, argv);
-  StringRef ProgName(sys::path::filename(argv[0]));
+static void reportCmdLineError(const Twine &Message) {
+  WithColor::error(errs(), ProgramName) << Message << "\n";
+}
+
+template <typename T>
+static bool parseNumericOption(const opt::Arg *A, T &Value) {
+  if (!A)
+    return true;
+  StringRef V = A->getValue();
+  T Parsed{};
+  if (!llvm::to_integer(V, Parsed, 0)) {
+    if (!std::numeric_limits<T>::is_signed && V == "-1") {
+      Value = std::numeric_limits<T>::max();
+      return true;
+    }
+    reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
+                       A->getSpelling() + "'");
+    return false;
+  }
+  Value = Parsed;
+  return true;
+}
+
+static bool parseFloatOption(const opt::Arg *A, float &Value) {
+  if (!A)
+    return true;
+  StringRef V = A->getValue();
+  double Parsed;
+  if (V.getAsDouble(Parsed)) {
+    reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
+                       A->getSpelling() + "'");
+    return false;
+  }
+  Value = static_cast<float>(Parsed);
+  return true;
+}
+
+static bool parseCutoffValues(const opt::InputArgList &Args,
+                              std::vector<uint32_t> &Cutoffs) {
+  Cutoffs.clear();
+  for (const opt::Arg *A : Args.filtered(OPT_detailed_summary_cutoffs)) {
+    SmallVector<StringRef, 4> Parts;
+    StringRef(A->getValue())
+        .split(Parts, ',', /*MaxSplit=*/-1,
+               /*KeepEmpty=*/false);
+    for (StringRef Part : Parts) {
+      uint32_t Parsed;
+      if (!llvm::to_integer(Part, Parsed, 0)) {
+        reportCmdLineError(Twine("invalid argument '") + Part +
+                           "' for option '" + A->getSpelling() + "'");
+        return false;
+      }
+      Cutoffs.push_back(Parsed);
+    }
+  }
+  return true;
+}
+
+static bool parseFSDiscriminatorPassArg(const opt::InputArgList &Args) {
+  const opt::Arg *A = Args.getLastArg(OPT_fs_discriminator_pass);
+  if (!A)
+    return true;
+
+  StringRef Value = A->getValue();
+  auto Parsed = StringSwitch<std::optional<FSDiscriminatorPass>>(Value)
+                    .Case("Base", FSDiscriminatorPass::Base)
+                    .Case("base", FSDiscriminatorPass::Base)
+                    .Case("Pass1", FSDiscriminatorPass::Pass1)
+                    .Case("pass1", FSDiscriminatorPass::Pass1)
+                    .Case("Pass2", FSDiscriminatorPass::Pass2)
+                    .Case("pass2", FSDiscriminatorPass::Pass2)
+                    .Case("Pass3", FSDiscriminatorPass::Pass3)
+                    .Case("pass3", FSDiscriminatorPass::Pass3)
+                    .Case("PassLast", FSDiscriminatorPass::PassLast)
+                    .Case("pass-last", FSDiscriminatorPass::PassLast)
+                    .Case("passlast", FSDiscriminatorPass::PassLast)
+                    .Default(std::nullopt);
+  if (!Parsed) {
+    reportCmdLineError(Twine("invalid argument '") + Value + "' for option '" +
+                       A->getSpelling() + "'");
+    return false;
+  }
+  FSDiscriminatorPassOption = *Parsed;
+  return true;
+}
+
+static bool validateSubcommandOptions(const opt::InputArgList &Args,
+                                      StringRef Subcommand) {
+  bool Valid = true;
+  for (const opt::Arg *A : Args) {
+    if (A->getOption().matches(OPT_UNKNOWN) ||
+        A->getOption().matches(OPT_INPUT))
+      continue;
+    if (A->getOption().isRegisteredSC(Subcommand))
+      continue;
+    reportCmdLineError(Twine("unknown command line argument '") +
+                       A->getSpelling() + "' for subcommand '" + Subcommand +
+                       "'. Try: '" + ProgramName + " " + Subcommand +
+                       " --help'");
+    Valid = false;
+  }
+  return Valid;
+}
+
+static void printSubcommandHelp(const ProfdataOptTable &Tbl,
+                                StringRef Subcommand, bool ShowHidden) {
+  SmallString<64> Usage;
+  Usage += ProgramName;
+  Usage += " ";
+  Usage += Subcommand;
+  Usage += " [options]";
+  Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data", ShowHidden,
+                /*ShowAllAliases=*/false, Visibility(), Subcommand);
+  outs() << "\nPass @FILE as argument to read options from FILE.\n";
+}
+
+static void printTopLevelHelp() {
+  outs() << "OVERVIEW: LLVM profile data\n\n"
+         << "USAGE: " << ProgramName << " <subcommand> [options]\n\n"
+         << "SUBCOMMANDS:\n";
+  for (const auto &SC : OptionSubCommands)
+    outs() << "  " << SC.Name << " - " << SC.HelpText << "\n";
+  outs() << "\n  Type \"" << ProgramName
+         << " <subcommand> --help\" to get more help on a specific "
+            "subcommand\n\n"
+         << "OPTIONS:\n  --help        Display this message\n"
+         << "  --version     Display the version\n";
+}
+
+static bool parseMergeOptions(const opt::InputArgList &Args) {
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
+  if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
+    ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
+
+  if (!parseNumericOption(
+          Args.getLastArg(OPT_max_debug_info_correlation_warnings),
+          MaxDbgCorrelationWarnings))
+    return false;
+  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
+  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
+  BinaryFilename = Args.getLastArgValue(OPT_binary_file).str();
+  DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory);
+  DebugInfod = Args.hasArg(OPT_debuginfod);
+
+  if (const opt::Arg *A = Args.getLastArg(OPT_correlate)) {
+    StringRef V = A->getValue();
+    auto Parsed = StringSwitch<std::optional<ProfCorrelatorKind>>(V)
+                      .Case("", InstrProfCorrelator::NONE)
+                      .Case("debug-info", InstrProfCorrelator::DEBUG_INFO)
+                      .Case("binary", InstrProfCorrelator::BINARY)
+                      .Default(std::nullopt);
+    if (!Parsed) {
+      reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
+                         A->getSpelling() + "'");
+      return false;
+    }
+    BIDFetcherProfileCorrelate = *Parsed;
+  }
+
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
+  InputFilenames = Args.getAllArgValues(OPT_INPUT);
+  WeightedInputFilenames = Args.getAllArgValues(OPT_weighted_input);
+
+  OutputFormat = PF_Ext_Binary;
+  if (const opt::Arg *Fmt =
+          Args.getLastArg(OPT_binary, OPT_extbinary, OPT_text, OPT_gcc)) {
+    if (Fmt->getOption().matches(OPT_binary))
+      OutputFormat = PF_Binary;
+    else if (Fmt->getOption().matches(OPT_gcc))
+      OutputFormat = PF_GCC;
+    else if (Fmt->getOption().matches(OPT_text))
+      OutputFormat = PF_Text;
+    else
+      OutputFormat = PF_Ext_Binary;
+  }
+
+  InputFilenamesFile = Args.getLastArgValue(OPT_input_files).str();
+  DumpInputFileList = Args.hasArg(OPT_dump_input_file_list);
+  RemappingFile = Args.getLastArgValue(OPT_remapping_file).str();
+  UseMD5 = Args.hasArg(OPT_use_md5);
+  CompressAllSections = Args.hasArg(OPT_compress_all_sections);
+  SampleMergeColdContext = Args.hasArg(OPT_sample_merge_cold_context);
+  SampleTrimColdContext = Args.hasArg(OPT_sample_trim_cold_context);
+  if (!parseNumericOption(
+          Args.getLastArg(OPT_sample_frame_depth_for_cold_context),
+          SampleColdContextFrameDepth))
+    return false;
+  if (!parseNumericOption(Args.getLastArg(OPT_output_size_limit),
+                          OutputSizeLimit))
+    return false;
+  GenPartialProfile = Args.hasArg(OPT_gen_partial_profile);
+  SplitLayout = Args.hasArg(OPT_split_layout);
+  SupplInstrWithSample =
+      Args.getLastArgValue(OPT_supplement_instr_with_sample).str();
+  if (!parseFloatOption(Args.getLastArg(OPT_zero_counter_threshold),
+                        ZeroCounterThreshold))
+    return false;
+  if (!parseNumericOption(Args.getLastArg(OPT_suppl_min_size_threshold),
+                          SupplMinSizeThreshold))
+    return false;
+  if (!parseNumericOption(Args.getLastArg(OPT_instr_prof_cold_threshold),
+                          InstrProfColdThreshold))
+    return false;
+  if (!parseNumericOption(
+          Args.getLastArg(OPT_temporal_profile_trace_reservoir_size),
+          TemporalProfTraceReservoirSize))
+    return false;
+  if (!parseNumericOption(
+          Args.getLastArg(OPT_temporal_profile_max_trace_length),
+          TemporalProfMaxTraceLength))
+    return false;
+  FuncNameNegativeFilter = Args.getLastArgValue(OPT_no_function).str();
+
+  StringRef FailureModeValue = Args.getLastArgValue(OPT_failure_mode, "any");
+  auto ParsedFailMode =
+      StringSwitch<std::optional<FailureMode>>(FailureModeValue)
+          .Case("warn", warnOnly)
+          .Case("any", failIfAnyAreInvalid)
+          .Case("all", failIfAllAreInvalid)
+          .Default(std::nullopt);
+  if (!ParsedFailMode) {
+    reportCmdLineError(Twine("invalid argument '") + FailureModeValue +
+                       "' for option '--failure-mode'");
+    return false;
+  }
+  FailMode = *ParsedFailMode;
+
+  OutputSparse = Args.hasArg(OPT_sparse);
+  if (!parseNumericOption(Args.getLastArg(OPT_num_threads), NumThreads))
+    return false;
+  ProfileSymbolListFile = Args.getLastArgValue(OPT_prof_sym_list).str();
+
+  if (const opt::Arg *A = Args.getLastArg(OPT_convert_sample_profile_layout)) {
+    StringRef Layout = A->getValue();
+    auto ParsedLayout = StringSwitch<std::optional<SampleProfileLayout>>(Layout)
+                            .Case("nest", SPL_Nest)
+                            .Case("flat", SPL_Flat)
+                            .Default(std::nullopt);
+    if (!ParsedLayout) {
+      reportCmdLineError(Twine("invalid argument '") + Layout +
+                         "' for option '" + A->getSpelling() + "'");
+      return false;
+    }
+    ProfileLayout = *ParsedLayout;
+  }
+
+  DropProfileSymbolList = Args.hasArg(OPT_drop_profile_symbol_list);
+  KeepVTableSymbols = Args.hasArg(OPT_keep_vtable_symbols);
+  DoWritePrevVersion = Args.hasArg(OPT_write_prev_version);
+
+  if (const opt::Arg *A = Args.getLastArg(OPT_memprof_version)) {
+    StringRef Version = A->getValue();
+    auto ParsedVersion =
+        StringSwitch<std::optional<memprof::IndexedVersion>>(Version)
+            .Case("2", memprof::Version2)
+            .Case("3", memprof::Version3)
+            .Case("4", memprof::Version4)
+            .Default(std::nullopt);
+    if (!ParsedVersion) {
+      reportCmdLineError(Twine("invalid argument '") + Version +
+                         "' for option '" + A->getSpelling() + "'");
+      return false;
+    }
+    MemProfVersionRequested = *ParsedVersion;
+  }
+
+  MemProfFullSchema = Args.hasArg(OPT_memprof_full_schema);
+  MemprofGenerateRandomHotness = Args.hasArg(OPT_memprof_random_hotness);
+  if (!parseNumericOption(Args.getLastArg(OPT_memprof_random_hotness_seed),
+                          MemprofGenerateRandomHotnessSeed))
+    return false;
+
+  if (!parseFSDiscriminatorPassArg(Args))
+    return false;
+
+  return true;
+}
+
+static bool parseShowOptions(const opt::InputArgList &Args) {
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
+  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
+  if (!Inputs.empty()) {
+    Filename = Inputs.front();
+    if (Inputs.size() > 1) {
+      reportCmdLineError("too many positional arguments");
+      return false;
+    }
+  }
+
+  if (!parseNumericOption(
+          Args.getLastArg(OPT_max_debug_info_correlation_warnings),
+          MaxDbgCorrelationWarnings))
+    return false;
+  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
+  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
+
+  ShowCounts = Args.hasArg(OPT_counts);
+  if (const opt::Arg *A = Args.getLastArg(OPT_show_format)) {
+    StringRef Value = A->getValue();
+    auto Parsed = StringSwitch<std::optional<ShowFormat>>(Value)
+                      .Case("text", ShowFormat::Text)
+                      .Case("json", ShowFormat::Json)
+                      .Case("yaml", ShowFormat::Yaml)
+                      .Default(std::nullopt);
+    if (!Parsed) {
+      reportCmdLineError(Twine("invalid argument '") + Value +
+                         "' for option '" + A->getSpelling() + "'");
+      return false;
+    }
+    SFormat = *Parsed;
+  }
+  TextFormat = Args.hasArg(OPT_text);
+  JsonFormat = Args.hasArg(OPT_json);
+  ShowIndirectCallTargets = Args.hasArg(OPT_ic_targets);
+  ShowVTables = Args.hasArg(OPT_show_vtables);
+  ShowMemOPSizes = Args.hasArg(OPT_memop_sizes);
+  ShowDetailedSummary = Args.hasArg(OPT_detailed_summary);
+  if (!parseCutoffValues(Args, DetailedSummaryCutoffs))
+    return false;
+  ShowHotFuncList = Args.hasArg(OPT_hot_func_list);
+  ShowAllFunctions = Args.hasArg(OPT_all_functions);
+  ShowCS = Args.hasArg(OPT_showcs);
+  if (!parseNumericOption(Args.getLastArg(OPT_topn), TopNFunctions))
+    return false;
+  if (!parseNumericOption(Args.getLastArg(OPT_value_cutoff), ShowValueCutoff))
+    return false;
+  OnlyListBelow = Args.hasArg(OPT_list_below_cutoff);
+  ShowProfileSymbolList = Args.hasArg(OPT_show_prof_sym_list);
+  ShowSectionInfoOnly = Args.hasArg(OPT_show_sec_info_only);
+  ShowBinaryIds = Args.hasArg(OPT_binary_ids);
+  ShowTemporalProfTraces = Args.hasArg(OPT_temporal_profile_traces);
+  ShowCovered = Args.hasArg(OPT_covered);
+  ShowProfileVersion = Args.hasArg(OPT_profile_version);
+
+  if (const opt::Arg *A = Args.getLastArg(OPT_memory, OPT_sample, OPT_instr)) {
+    if (A->getOption().matches(OPT_memory))
+      ShowProfileKind = memory;
+    else if (A->getOption().matches(OPT_sample))
+      ShowProfileKind = sample;
+    else
+      ShowProfileKind = instr;
+  }
+
+  if (!parseFSDiscriminatorPassArg(Args))
+    return false;
+
+  return true;
+}
+
+static bool parseOverlapOptions(const opt::InputArgList &Args) {
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
+  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
+  if (Inputs.size() != 2) {
+    reportCmdLineError("overlap requires two positional profile filenames");
+    return false;
+  }
+  BaseFilename = Inputs[0];
+  TestFilename = Inputs[1];
+
+  if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
+    ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
+
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
+  if (!parseNumericOption(Args.getLastArg(OPT_similarity_cutoff),
+                          SimilarityCutoff))
+    return false;
+  IsCS = Args.hasArg(OPT_cs);
+  if (!parseNumericOption(Args.getLastArg(OPT_value_cutoff),
+                          OverlapValueCutoff))
+    return false;
+
+  if (!parseFSDiscriminatorPassArg(Args))
+    return false;
+
+  return true;
+}
+
+static bool parseOrderOptions(const opt::InputArgList &Args) {
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
+  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
+  if (!Inputs.empty()) {
+    Filename = Inputs.front();
+    if (Inputs.size() > 1) {
+      reportCmdLineError("too many positional arguments");
+      return false;
+    }
+  }
+  if (!parseNumericOption(Args.getLastArg(OPT_num_test_traces), NumTestTraces))
+    return false;
+  return true;
+}
+
+int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) {
+  BumpPtrAllocator Alloc;
+  StringSaver Saver(Alloc);
+
+  ProgramName = sys::path::filename(argv[0]).str();
 
   if (argc < 2) {
-    errs()
-        << ProgName
-        << ": No subcommand specified! Run llvm-profdata --help for usage.\n";
+    errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
+           << " --help for usage.\n";
     return 1;
   }
 
-  cl::ParseCommandLineOptions(argc, argv, "LLVM profile data\n");
+  StringRef Subcommand = argv[1];
+  if (Subcommand == "--help" || Subcommand == "-help" || Subcommand == "-h") {
+    printTopLevelHelp();
+    return 0;
+  }
 
-  if (ShowSubcommand)
-    return show_main(ProgName);
+  if (Subcommand == "--version" || Subcommand == "-version") {
+    outs() << ProgramName << '\n';
+    cl::PrintVersionMessage();
+    return 0;
+  }
 
-  if (OrderSubcommand)
-    return order_main();
+  if (Subcommand != "show" && Subcommand != "order" &&
+      Subcommand != "overlap" && Subcommand != "merge") {
+    errs() << ProgramName << ": Unknown command. Run " << ProgramName
+           << " --help for usage.\n";
+    return 1;
+  }
 
-  if (OverlapSubcommand)
-    return overlap_main();
+  ProfdataOptTable Tbl;
+  bool HadParseError = false;
+  opt::InputArgList Args =
+      Tbl.parseArgs(argc - 2, argv + 2, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
+        WithColor::error(errs(), ProgramName) << Msg << "\n";
+        HadParseError = true;
+      });
+  if (HadParseError)
+    return 1;
 
-  if (MergeSubcommand)
-    return merge_main(ProgName);
+  bool ShowHidden = Args.hasArg(OPT_help_hidden);
+  if (Args.hasArg(OPT_help) || ShowHidden) {
+    printSubcommandHelp(Tbl, Subcommand, ShowHidden);
+    return 0;
+  }
+
+  if (!validateSubcommandOptions(Args, Subcommand))
+    return 1;
+
+  if (Args.hasArg(OPT_version)) {
+    outs() << ProgramName << '\n';
+    cl::PrintVersionMessage();
+    return 0;
+  }
+
+  if (Subcommand == "merge") {
+    if (!parseMergeOptions(Args))
+      return 1;
+    return merge_main(ProgramName);
+  }
+  if (Subcommand == "show") {
+    if (!parseShowOptions(Args))
+      return 1;
+    return show_main(ProgramName);
+  }
+  if (Subcommand == "overlap") {
+    if (!parseOverlapOptions(Args))
+      return 1;
+    return overlap_main();
+  }
+  if (Subcommand == "order") {
+    if (!parseOrderOptions(Args))
+      return 1;
+    return order_main();
+  }
 
-  errs() << ProgName
-         << ": Unknown command. Run llvm-profdata --help for usage.\n";
+  errs() << ProgramName << ": Unknown command. Run " << ProgramName
+         << " --help for usage.\n";
   return 1;
 }
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index e83a237a5397f..e02631d34a382 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -5843,12 +5843,23 @@ cc_library(
         ":Core",
         ":Debuginfod",
         ":Object",
+        ":Option",
+        ":ProfdataOptsTableGen",
         ":ProfileData",
         ":Support",
     ],
 )
 
-cc_binary(
+gentbl_cc_library(
+    name = "ProfdataOptsTableGen",
+    strip_include_prefix = "tools/llvm-profdata",
+    tbl_outs = {"tools/llvm-profdata/Opts.inc": ["-gen-opt-parser-defs"]},
+    tblgen = ":llvm-tblgen",
+    td_file = "tools/llvm-profdata/Opts.td",
+    deps = [":OptParserTdFiles"],
+)
+
+llvm_driver_cc_binary(
     name = "llvm-profdata",
     stamp = 0,
     deps = [":llvm-profdata-lib"],
diff --git a/utils/bazel/llvm-project-overlay/llvm/driver.bzl b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
index e38c681370ed1..331e3f7e0db1f 100644
--- a/utils/bazel/llvm-project-overlay/llvm/driver.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
@@ -28,6 +28,7 @@ _TOOLS = {
     "llvm-nm": "//llvm:llvm-nm-lib",
     "llvm-objcopy": "//llvm:llvm-objcopy-lib",
     "llvm-objdump": "//llvm:llvm-objdump-lib",
+    "llvm-profdata": "//llvm:llvm-profdata-lib",
     "llvm-rc": "//llvm:llvm-rc-lib",
     "llvm-readobj": "//llvm:llvm-readobj-lib",
     "llvm-size": "//llvm:llvm-size-lib",

>From 1b7e425d8310138cce51d36e8d3495fec7fe870b Mon Sep 17 00:00:00 2001
From: David Zbarsky <dzbarsky at gmail.com>
Date: Mon, 26 Jan 2026 13:53:58 -0500
Subject: [PATCH 2/3] CR feedback

---
 llvm/test/tools/llvm-profdata/help.test    |  22 ++
 llvm/tools/llvm-profdata/Opts.td           |  70 +++-
 llvm/tools/llvm-profdata/llvm-profdata.cpp | 414 ++++++++++++++++-----
 3 files changed, 403 insertions(+), 103 deletions(-)
 create mode 100644 llvm/test/tools/llvm-profdata/help.test

diff --git a/llvm/test/tools/llvm-profdata/help.test b/llvm/test/tools/llvm-profdata/help.test
new file mode 100644
index 0000000000000..b1b1c6da8dd72
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/help.test
@@ -0,0 +1,22 @@
+# RUN: llvm-profdata --help | FileCheck %s --check-prefix=TOP
+# RUN: llvm-profdata merge --help | FileCheck %s --check-prefix=MERGE
+# RUN: llvm-profdata show --help | FileCheck %s --check-prefix=SHOW
+
+# TOP: OVERVIEW: LLVM profile data
+# TOP: USAGE: llvm-profdata [subcommand] [options]
+# TOP: SUBCOMMANDS:
+# TOP: merge - Takes several profiles and merge them together.
+# TOP: show - Takes a profile data file and displays the profiles.
+
+# MERGE: OVERVIEW: LLVM profile data
+# MERGE: Takes several profiles and merge them together.
+# MERGE: OPTIONS:
+# MERGE: -instr
+# MERGE: -output <output>
+# MERGE: -sample
+
+# SHOW: OVERVIEW: LLVM profile data
+# SHOW: Takes a profile data file and displays the profiles.
+# SHOW: OPTIONS:
+# SHOW: -output <output>
+# SHOW: -show-format
diff --git a/llvm/tools/llvm-profdata/Opts.td b/llvm/tools/llvm-profdata/Opts.td
index 8803af9a10123..5244e9638ff16 100644
--- a/llvm/tools/llvm-profdata/Opts.td
+++ b/llvm/tools/llvm-profdata/Opts.td
@@ -118,6 +118,11 @@ def compress_all_sections
       HelpText<"Compress all sections when writing the profile (only "
                "meaningful for -extbinary)">,
       Flags<[HelpHidden]>;
+def compress_all_sections_EQ
+    : Joined<["-","--"], "compress-all-sections=", [Merge]>,
+      HelpText<"Compress all sections when writing the profile (only "
+               "meaningful for -extbinary)">,
+      Flags<[HelpHidden]>;
 def sample_merge_cold_context
     : Flag<["-","--"], "sample-merge-cold-context", [Merge]>,
       HelpText<"Merge context sample profiles whose count is below cold "
@@ -188,8 +193,65 @@ def failure_mode
     : JoinedOrSeparate<["-","--"], "failure-mode", [Merge]>,
       HelpText<"Failure mode: warn, any, or all">,
       MetaVarName<"<mode>">;
-def sparse : Flag<["-","--"], "sparse", [Merge]>,
-             HelpText<"Generate a sparse profile (only meaningful for -instr)">;
+def sparse
+    : Flag<["-","--"], "sparse", [Merge]>,
+      HelpText<"Generate a sparse profile (only meaningful for -instr)">;
+def sparse_EQ
+    : Joined<["-","--"], "sparse=", [Merge]>,
+      HelpText<"Generate a sparse profile (only meaningful for -instr)">,
+      Flags<[HelpHidden]>;
+
+def profile_isfs : Flag<["-","--"], "profile-isfs", [Show, Merge]>,
+                   HelpText<"Profile uses flow-sensitive discriminators">,
+                   Flags<[HelpHidden]>;
+
+def generate_merged_base_profiles
+    : JoinedOrSeparate<["-","--"], "generate-merged-base-profiles", [Merge]>,
+      HelpText<"Generate merged base profiles when creating nested "
+               "context-sensitive profiles">,
+      Flags<[HelpHidden]>;
+
+def profile_symbol_list_cutoff
+    : JoinedOrSeparate<["-","--"], "profile-symbol-list-cutoff", [Merge]>,
+      HelpText<"Maximum number of symbols to keep in the profile symbol list">,
+      Flags<[HelpHidden]>;
+def profile_summary_cutoff_hot
+    : JoinedOrSeparate<["-","--"], "profile-summary-cutoff-hot",
+                       [Show, Merge]>,
+      HelpText<"Percentile (times 10000) for determining hot threshold">,
+      Flags<[HelpHidden]>;
+def profile_summary_cutoff_cold
+    : JoinedOrSeparate<["-","--"], "profile-summary-cutoff-cold",
+                       [Show, Merge]>,
+      HelpText<"Percentile (times 10000) for determining cold threshold">,
+      Flags<[HelpHidden]>;
+def profile_summary_hot_count
+    : JoinedOrSeparate<["-","--"], "profile-summary-hot-count",
+                       [Show, Merge]>,
+      HelpText<"Override hot count derived from summary cutoffs">,
+      Flags<[HelpHidden]>;
+def profile_summary_cold_count
+    : JoinedOrSeparate<["-","--"], "profile-summary-cold-count",
+                       [Show, Merge]>,
+      HelpText<"Override cold count derived from summary cutoffs">,
+      Flags<[HelpHidden]>;
+def profile_summary_contextless
+    : JoinedOrSeparate<["-","--"], "profile-summary-contextless",
+                       [Show, Merge]>,
+      HelpText<"Merge context profiles before calculating summary thresholds">,
+      Flags<[HelpHidden]>;
+def profile_summary_huge_working_set_size_threshold
+    : JoinedOrSeparate<["-","--"],
+                       "profile-summary-huge-working-set-size-threshold",
+                       [Show, Merge]>,
+      HelpText<"Threshold for huge working set size used in profile summary">,
+      Flags<[HelpHidden]>;
+def profile_summary_large_working_set_size_threshold
+    : JoinedOrSeparate<["-","--"],
+                       "profile-summary-large-working-set-size-threshold",
+                       [Show, Merge]>,
+      HelpText<"Threshold for large working set size used in profile summary">,
+      Flags<[HelpHidden]>;
 def num_threads : JoinedOrSeparate<["-","--"], "num-threads", [Merge]>,
                   HelpText<"Number of merge threads to use (default: autodetect)">,
                   MetaVarName<"<n>">;
@@ -261,6 +323,10 @@ def ic_targets : Flag<["-","--"], "ic-targets", [Show]>,
                  HelpText<"Show indirect call site target values">;
 def show_vtables : Flag<["-","--"], "show-vtables", [Show]>,
                    HelpText<"Show vtable names for shown functions">;
+def extbinary_write_vtable_type_prof
+    : Flag<["-","--"], "extbinary-write-vtable-type-prof", [Merge]>,
+      HelpText<"Include vtable type profile data in ext-binary sample profile">,
+      Flags<[HelpHidden]>;
 def memop_sizes : Flag<["-","--"], "memop-sizes", [Show]>,
                   HelpText<"Show profiled sizes of memory intrinsic calls">;
 def detailed_summary : Flag<["-","--"], "detailed-summary", [Show]>,
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 4c8c7519df9ca..5215578eede46 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -3168,11 +3168,56 @@ static void reportCmdLineError(const Twine &Message) {
   WithColor::error(errs(), ProgramName) << Message << "\n";
 }
 
+static StringRef getOptionValue(const opt::Arg *A) {
+  if (A->getNumValues() == 0)
+    return StringRef();
+  StringRef V = A->getValue();
+  V.consume_front("=");
+  return V;
+}
+
+static std::string getLastArgValueClean(const opt::InputArgList &Args,
+                                        unsigned OptionID,
+                                        StringRef Default = "") {
+  if (const opt::Arg *A = Args.getLastArg(OptionID))
+    return getOptionValue(A).str();
+  return Default.str();
+}
+
+static std::vector<std::string>
+getAllArgValuesClean(const opt::InputArgList &Args, unsigned OptionID) {
+  std::vector<std::string> Values;
+  for (const opt::Arg *A : Args.filtered(OptionID))
+    Values.push_back(getOptionValue(A).str());
+  return Values;
+}
+
+static bool parseBooleanOption(const opt::Arg *A, bool &Value) {
+  if (!A)
+    return true;
+  StringRef V = getOptionValue(A);
+  if (V.empty()) {
+    Value = true;
+    return true;
+  }
+  if (V.equals_insensitive("true") || V == "1") {
+    Value = true;
+    return true;
+  }
+  if (V.equals_insensitive("false") || V == "0") {
+    Value = false;
+    return true;
+  }
+  reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
+                     A->getSpelling() + "'");
+  return false;
+}
+
 template <typename T>
 static bool parseNumericOption(const opt::Arg *A, T &Value) {
   if (!A)
     return true;
-  StringRef V = A->getValue();
+  StringRef V = getOptionValue(A);
   T Parsed{};
   if (!llvm::to_integer(V, Parsed, 0)) {
     if (!std::numeric_limits<T>::is_signed && V == "-1") {
@@ -3187,10 +3232,86 @@ static bool parseNumericOption(const opt::Arg *A, T &Value) {
   return true;
 }
 
+static bool applyLibraryOptionsWithCL(const opt::InputArgList &Args) {
+  SmallVector<std::string, 16> CLStrings;
+  CLStrings.push_back(ProgramName);
+
+  auto AddBool = [&](unsigned OptID, StringRef Spelling) -> bool {
+    if (const opt::Arg *A = Args.getLastArg(OptID)) {
+      bool Value = true;
+      if (!parseBooleanOption(A, Value))
+        return false;
+      CLStrings.push_back(
+          (Spelling + Twine("=") + (Value ? "true" : "false")).str());
+    }
+    return true;
+  };
+  auto AddUInt = [&](unsigned OptID, StringRef Spelling) -> bool {
+    if (const opt::Arg *A = Args.getLastArg(OptID)) {
+      uint64_t Value = 0;
+      if (!parseNumericOption(A, Value))
+        return false;
+      CLStrings.push_back((Spelling + Twine("=") + Twine(Value)).str());
+    }
+    return true;
+  };
+  auto AddInt = [&](unsigned OptID, StringRef Spelling) -> bool {
+    if (const opt::Arg *A = Args.getLastArg(OptID)) {
+      int Value = 0;
+      if (!parseNumericOption(A, Value))
+        return false;
+      CLStrings.push_back((Spelling + Twine("=") + Twine(Value)).str());
+    }
+    return true;
+  };
+
+  if (!AddBool(OPT_profile_isfs, "--profile-isfs"))
+    return false;
+  if (!AddBool(OPT_generate_merged_base_profiles,
+               "--generate-merged-base-profiles"))
+    return false;
+  if (!AddUInt(OPT_profile_symbol_list_cutoff, "--profile-symbol-list-cutoff"))
+    return false;
+  if (!AddBool(OPT_extbinary_write_vtable_type_prof,
+               "--extbinary-write-vtable-type-prof"))
+    return false;
+
+  if (!AddBool(OPT_profile_summary_contextless,
+               "--profile-summary-contextless"))
+    return false;
+  if (!AddInt(OPT_profile_summary_cutoff_hot, "--profile-summary-cutoff-hot"))
+    return false;
+  if (!AddInt(OPT_profile_summary_cutoff_cold, "--profile-summary-cutoff-cold"))
+    return false;
+  if (!AddUInt(OPT_profile_summary_hot_count, "--profile-summary-hot-count"))
+    return false;
+  if (!AddUInt(OPT_profile_summary_cold_count, "--profile-summary-cold-count"))
+    return false;
+  if (!AddUInt(OPT_profile_summary_huge_working_set_size_threshold,
+               "--profile-summary-huge-working-set-size-threshold"))
+    return false;
+  if (!AddUInt(OPT_profile_summary_large_working_set_size_threshold,
+               "--profile-summary-large-working-set-size-threshold"))
+    return false;
+
+  if (CLStrings.size() == 1)
+    return true;
+
+  SmallVector<char *, 16> CLArgs;
+  for (std::string &S : CLStrings)
+    CLArgs.push_back(S.data());
+
+  return cl::ParseCommandLineOptions(CLArgs.size(), CLArgs.data(),
+                                     /*Overview=*/"", /*Errs=*/nullptr,
+                                     /*VFS=*/nullptr,
+                                     /*EnvVar=*/nullptr,
+                                     /*LongOptionsUseDoubleDash=*/false);
+}
+
 static bool parseFloatOption(const opt::Arg *A, float &Value) {
   if (!A)
     return true;
-  StringRef V = A->getValue();
+  StringRef V = getOptionValue(A);
   double Parsed;
   if (V.getAsDouble(Parsed)) {
     reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
@@ -3206,9 +3327,17 @@ static bool parseCutoffValues(const opt::InputArgList &Args,
   Cutoffs.clear();
   for (const opt::Arg *A : Args.filtered(OPT_detailed_summary_cutoffs)) {
     SmallVector<StringRef, 4> Parts;
-    StringRef(A->getValue())
-        .split(Parts, ',', /*MaxSplit=*/-1,
-               /*KeepEmpty=*/false);
+    if (A->getNumValues() <= 1) {
+      getOptionValue(A).split(Parts, ',', /*MaxSplit=*/-1,
+                              /*KeepEmpty=*/false);
+    } else {
+      for (unsigned I = 0, E = A->getNumValues(); I != E; ++I) {
+        StringRef Part = A->getValue(I);
+        if (!Part.empty() && Part.front() == '=')
+          Part = Part.drop_front();
+        Parts.push_back(Part);
+      }
+    }
     for (StringRef Part : Parts) {
       uint32_t Parsed;
       if (!llvm::to_integer(Part, Parsed, 0)) {
@@ -3227,7 +3356,7 @@ static bool parseFSDiscriminatorPassArg(const opt::InputArgList &Args) {
   if (!A)
     return true;
 
-  StringRef Value = A->getValue();
+  StringRef Value = getOptionValue(A);
   auto Parsed = StringSwitch<std::optional<FSDiscriminatorPass>>(Value)
                     .Case("Base", FSDiscriminatorPass::Base)
                     .Case("base", FSDiscriminatorPass::Base)
@@ -3268,48 +3397,26 @@ static bool validateSubcommandOptions(const opt::InputArgList &Args,
   return Valid;
 }
 
-static void printSubcommandHelp(const ProfdataOptTable &Tbl,
-                                StringRef Subcommand, bool ShowHidden) {
-  SmallString<64> Usage;
-  Usage += ProgramName;
-  Usage += " ";
-  Usage += Subcommand;
-  Usage += " [options]";
-  Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data", ShowHidden,
-                /*ShowAllAliases=*/false, Visibility(), Subcommand);
-  outs() << "\nPass @FILE as argument to read options from FILE.\n";
-}
-
-static void printTopLevelHelp() {
-  outs() << "OVERVIEW: LLVM profile data\n\n"
-         << "USAGE: " << ProgramName << " <subcommand> [options]\n\n"
-         << "SUBCOMMANDS:\n";
-  for (const auto &SC : OptionSubCommands)
-    outs() << "  " << SC.Name << " - " << SC.HelpText << "\n";
-  outs() << "\n  Type \"" << ProgramName
-         << " <subcommand> --help\" to get more help on a specific "
-            "subcommand\n\n"
-         << "OPTIONS:\n  --help        Display this message\n"
-         << "  --version     Display the version\n";
-}
-
-static bool parseMergeOptions(const opt::InputArgList &Args) {
-  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
+static bool parseMergeOptions(const opt::InputArgList &Args,
+                              ArrayRef<StringRef> Positionals) {
+  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
   if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
     ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
+  if (!applyLibraryOptionsWithCL(Args))
+    return false;
 
   if (!parseNumericOption(
           Args.getLastArg(OPT_max_debug_info_correlation_warnings),
           MaxDbgCorrelationWarnings))
     return false;
-  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
-  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
-  BinaryFilename = Args.getLastArgValue(OPT_binary_file).str();
-  DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory);
+  ProfiledBinary = getLastArgValueClean(Args, OPT_profiled_binary);
+  DebugInfoFilename = getLastArgValueClean(Args, OPT_debug_info);
+  BinaryFilename = getLastArgValueClean(Args, OPT_binary_file);
+  DebugFileDirectory = getAllArgValuesClean(Args, OPT_debug_file_directory);
   DebugInfod = Args.hasArg(OPT_debuginfod);
 
   if (const opt::Arg *A = Args.getLastArg(OPT_correlate)) {
-    StringRef V = A->getValue();
+    StringRef V = getOptionValue(A);
     auto Parsed = StringSwitch<std::optional<ProfCorrelatorKind>>(V)
                       .Case("", InstrProfCorrelator::NONE)
                       .Case("debug-info", InstrProfCorrelator::DEBUG_INFO)
@@ -3323,9 +3430,12 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
     BIDFetcherProfileCorrelate = *Parsed;
   }
 
-  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
-  InputFilenames = Args.getAllArgValues(OPT_INPUT);
-  WeightedInputFilenames = Args.getAllArgValues(OPT_weighted_input);
+  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
+  InputFilenames.clear();
+  InputFilenames.reserve(Positionals.size());
+  for (StringRef Pos : Positionals)
+    InputFilenames.emplace_back(Pos.str());
+  WeightedInputFilenames = getAllArgValuesClean(Args, OPT_weighted_input);
 
   OutputFormat = PF_Ext_Binary;
   if (const opt::Arg *Fmt =
@@ -3340,11 +3450,15 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
       OutputFormat = PF_Ext_Binary;
   }
 
-  InputFilenamesFile = Args.getLastArgValue(OPT_input_files).str();
+  InputFilenamesFile = getLastArgValueClean(Args, OPT_input_files);
   DumpInputFileList = Args.hasArg(OPT_dump_input_file_list);
-  RemappingFile = Args.getLastArgValue(OPT_remapping_file).str();
+  RemappingFile = getLastArgValueClean(Args, OPT_remapping_file);
   UseMD5 = Args.hasArg(OPT_use_md5);
-  CompressAllSections = Args.hasArg(OPT_compress_all_sections);
+  const opt::Arg *CompressArg =
+      Args.getLastArg(OPT_compress_all_sections, OPT_compress_all_sections_EQ);
+  CompressAllSections = CompressArg != nullptr;
+  if (!parseBooleanOption(CompressArg, CompressAllSections))
+    return false;
   SampleMergeColdContext = Args.hasArg(OPT_sample_merge_cold_context);
   SampleTrimColdContext = Args.hasArg(OPT_sample_trim_cold_context);
   if (!parseNumericOption(
@@ -3357,7 +3471,7 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
   GenPartialProfile = Args.hasArg(OPT_gen_partial_profile);
   SplitLayout = Args.hasArg(OPT_split_layout);
   SupplInstrWithSample =
-      Args.getLastArgValue(OPT_supplement_instr_with_sample).str();
+      getLastArgValueClean(Args, OPT_supplement_instr_with_sample);
   if (!parseFloatOption(Args.getLastArg(OPT_zero_counter_threshold),
                         ZeroCounterThreshold))
     return false;
@@ -3375,9 +3489,12 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
           Args.getLastArg(OPT_temporal_profile_max_trace_length),
           TemporalProfMaxTraceLength))
     return false;
-  FuncNameNegativeFilter = Args.getLastArgValue(OPT_no_function).str();
+  FuncNameNegativeFilter = getLastArgValueClean(Args, OPT_no_function);
 
-  StringRef FailureModeValue = Args.getLastArgValue(OPT_failure_mode, "any");
+  StringRef FailureModeValue =
+      Args.getLastArg(OPT_failure_mode)
+          ? getOptionValue(Args.getLastArg(OPT_failure_mode))
+          : StringRef("any");
   auto ParsedFailMode =
       StringSwitch<std::optional<FailureMode>>(FailureModeValue)
           .Case("warn", warnOnly)
@@ -3391,13 +3508,16 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
   }
   FailMode = *ParsedFailMode;
 
-  OutputSparse = Args.hasArg(OPT_sparse);
+  const opt::Arg *SparseArg = Args.getLastArg(OPT_sparse, OPT_sparse_EQ);
+  OutputSparse = SparseArg != nullptr;
+  if (!parseBooleanOption(SparseArg, OutputSparse))
+    return false;
   if (!parseNumericOption(Args.getLastArg(OPT_num_threads), NumThreads))
     return false;
-  ProfileSymbolListFile = Args.getLastArgValue(OPT_prof_sym_list).str();
+  ProfileSymbolListFile = getLastArgValueClean(Args, OPT_prof_sym_list);
 
   if (const opt::Arg *A = Args.getLastArg(OPT_convert_sample_profile_layout)) {
-    StringRef Layout = A->getValue();
+    StringRef Layout = getOptionValue(A);
     auto ParsedLayout = StringSwitch<std::optional<SampleProfileLayout>>(Layout)
                             .Case("nest", SPL_Nest)
                             .Case("flat", SPL_Flat)
@@ -3415,7 +3535,7 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
   DoWritePrevVersion = Args.hasArg(OPT_write_prev_version);
 
   if (const opt::Arg *A = Args.getLastArg(OPT_memprof_version)) {
-    StringRef Version = A->getValue();
+    StringRef Version = getOptionValue(A);
     auto ParsedVersion =
         StringSwitch<std::optional<memprof::IndexedVersion>>(Version)
             .Case("2", memprof::Version2)
@@ -3442,12 +3562,12 @@ static bool parseMergeOptions(const opt::InputArgList &Args) {
   return true;
 }
 
-static bool parseShowOptions(const opt::InputArgList &Args) {
-  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
-  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
-  if (!Inputs.empty()) {
-    Filename = Inputs.front();
-    if (Inputs.size() > 1) {
+static bool parseShowOptions(const opt::InputArgList &Args,
+                             ArrayRef<StringRef> Positionals) {
+  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  if (!Positionals.empty()) {
+    Filename = Positionals.front().str();
+    if (Positionals.size() > 1) {
       reportCmdLineError("too many positional arguments");
       return false;
     }
@@ -3457,13 +3577,15 @@ static bool parseShowOptions(const opt::InputArgList &Args) {
           Args.getLastArg(OPT_max_debug_info_correlation_warnings),
           MaxDbgCorrelationWarnings))
     return false;
-  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
-  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
-  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
+  if (!applyLibraryOptionsWithCL(Args))
+    return false;
+  ProfiledBinary = getLastArgValueClean(Args, OPT_profiled_binary);
+  DebugInfoFilename = getLastArgValueClean(Args, OPT_debug_info);
+  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
 
   ShowCounts = Args.hasArg(OPT_counts);
   if (const opt::Arg *A = Args.getLastArg(OPT_show_format)) {
-    StringRef Value = A->getValue();
+    StringRef Value = getOptionValue(A);
     auto Parsed = StringSwitch<std::optional<ShowFormat>>(Value)
                       .Case("text", ShowFormat::Text)
                       .Case("json", ShowFormat::Json)
@@ -3514,20 +3636,20 @@ static bool parseShowOptions(const opt::InputArgList &Args) {
   return true;
 }
 
-static bool parseOverlapOptions(const opt::InputArgList &Args) {
-  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
-  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
-  if (Inputs.size() != 2) {
+static bool parseOverlapOptions(const opt::InputArgList &Args,
+                                ArrayRef<StringRef> Positionals) {
+  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  if (Positionals.size() != 2) {
     reportCmdLineError("overlap requires two positional profile filenames");
     return false;
   }
-  BaseFilename = Inputs[0];
-  TestFilename = Inputs[1];
+  BaseFilename = Positionals[0].str();
+  TestFilename = Positionals[1].str();
 
   if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
     ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
 
-  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
+  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
   if (!parseNumericOption(Args.getLastArg(OPT_similarity_cutoff),
                           SimilarityCutoff))
     return false;
@@ -3542,12 +3664,12 @@ static bool parseOverlapOptions(const opt::InputArgList &Args) {
   return true;
 }
 
-static bool parseOrderOptions(const opt::InputArgList &Args) {
-  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
-  std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
-  if (!Inputs.empty()) {
-    Filename = Inputs.front();
-    if (Inputs.size() > 1) {
+static bool parseOrderOptions(const opt::InputArgList &Args,
+                              ArrayRef<StringRef> Positionals) {
+  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  if (!Positionals.empty()) {
+    Filename = Positionals.front().str();
+    if (Positionals.size() > 1) {
       reportCmdLineError("too many positional arguments");
       return false;
     }
@@ -3561,49 +3683,139 @@ int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) {
   BumpPtrAllocator Alloc;
   StringSaver Saver(Alloc);
 
-  ProgramName = sys::path::filename(argv[0]).str();
-
-  if (argc < 2) {
-    errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
-           << " --help for usage.\n";
-    return 1;
-  }
-
-  StringRef Subcommand = argv[1];
-  if (Subcommand == "--help" || Subcommand == "-help" || Subcommand == "-h") {
-    printTopLevelHelp();
-    return 0;
-  }
+  ProgramName = sys::path::stem(argv[0]).str();
 
-  if (Subcommand == "--version" || Subcommand == "-version") {
-    outs() << ProgramName << '\n';
-    cl::PrintVersionMessage();
-    return 0;
+  ProfdataOptTable Tbl;
+  ArrayRef<opt::OptTable::SubCommand> KnownSubcommands = Tbl.getSubCommands();
+  auto IsKnownSubcommand = [&](StringRef Name) {
+    return llvm::any_of(
+        KnownSubcommands,
+        [&](const opt::OptTable::SubCommand &SC) { return Name == SC.Name; });
+  };
+  ArrayRef<const char *> RawArgs(argv + 1, argv + argc);
+  SmallVector<StringRef, 4> RawSubcommands;
+  for (const char *Arg : RawArgs) {
+    StringRef ArgRef(Arg);
+    if (!ArgRef.starts_with("-") && IsKnownSubcommand(ArgRef))
+      RawSubcommands.push_back(ArgRef);
+  }
+  auto HasFlag = [&](StringRef Flag) {
+    return llvm::is_contained(RawArgs, Flag);
+  };
+  auto HasAnySubcommand = [&]() { return !RawSubcommands.empty(); };
+
+  if (!HasAnySubcommand()) {
+    if (HasFlag("--help") || HasFlag("-help") || HasFlag("-h")) {
+      std::string Usage = ProgramName + " [subcommand] [options]";
+      Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
+                    /*ShowHidden=*/false, /*ShowAllAliases=*/false,
+                    Visibility(), /*Subcommand=*/{});
+      return 0;
+    }
+    if (HasFlag("--help-hidden")) {
+      std::string Usage = ProgramName + " [subcommand] [options]";
+      Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
+                    /*ShowHidden=*/true, /*ShowAllAliases=*/false, Visibility(),
+                    /*Subcommand=*/{});
+      return 0;
+    }
+    if (HasFlag("--version") || HasFlag("-version")) {
+      outs() << ProgramName << '\n';
+      cl::PrintVersionMessage();
+      return 0;
+    }
   }
 
-  if (Subcommand != "show" && Subcommand != "order" &&
-      Subcommand != "overlap" && Subcommand != "merge") {
-    errs() << ProgramName << ": Unknown command. Run " << ProgramName
+  if (argc <= 1) {
+    errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
            << " --help for usage.\n";
     return 1;
   }
 
-  ProfdataOptTable Tbl;
   bool HadParseError = false;
   opt::InputArgList Args =
-      Tbl.parseArgs(argc - 2, argv + 2, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
+      Tbl.parseArgs(argc - 1, argv + 1, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
         WithColor::error(errs(), ProgramName) << Msg << "\n";
         HadParseError = true;
       });
   if (HadParseError)
     return 1;
 
+  bool HadSubcommandError = false;
+  SmallVector<StringRef, 4> OtherPositionals;
+  auto HandleMultipleSubcommands = [&](ArrayRef<StringRef> SubCommands) {
+    HadSubcommandError = true;
+    WithColor::error(errs(), ProgramName) << "multiple subcommands specified:";
+    for (StringRef SC : SubCommands)
+      errs() << " '" << SC << "'";
+    errs() << ".\n";
+  };
+  auto HandleOtherPositionals = [&](ArrayRef<StringRef> Positionals) {
+    OtherPositionals.append(Positionals.begin(), Positionals.end());
+  };
+
+  StringRef Subcommand = Args.getSubCommand(
+      Tbl.getSubCommands(), HandleMultipleSubcommands, HandleOtherPositionals);
+  if (HadSubcommandError)
+    return 1;
+
+  if (Subcommand.empty() && RawSubcommands.size() > 1) {
+    HadSubcommandError = true;
+    HandleMultipleSubcommands(RawSubcommands);
+  }
+  if (HadSubcommandError)
+    return 1;
+
+  if (Subcommand.empty() && argc > 1 && IsKnownSubcommand(argv[1]))
+    Subcommand = argv[1];
+  if (Subcommand.empty() && !OtherPositionals.empty() &&
+      IsKnownSubcommand(OtherPositionals.front())) {
+    Subcommand = OtherPositionals.front();
+    OtherPositionals.erase(OtherPositionals.begin());
+  }
+  if (Subcommand.empty() && RawSubcommands.size() == 1)
+    Subcommand = RawSubcommands.front();
+  if (!Subcommand.empty()) {
+    auto It = llvm::find(OtherPositionals, Subcommand);
+    if (It != OtherPositionals.end())
+      OtherPositionals.erase(It);
+  }
+
+  ArrayRef<StringRef> Positionals = OtherPositionals;
+
   bool ShowHidden = Args.hasArg(OPT_help_hidden);
   if (Args.hasArg(OPT_help) || ShowHidden) {
-    printSubcommandHelp(Tbl, Subcommand, ShowHidden);
+    std::string Usage = ProgramName + " [subcommand] [options]";
+    Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
+                  /*ShowHidden=*/ShowHidden, /*ShowAllAliases=*/false,
+                  Visibility(), Subcommand);
     return 0;
   }
 
+  if (Subcommand.empty()) {
+    if (Args.hasArg(OPT_version)) {
+      outs() << ProgramName << '\n';
+      cl::PrintVersionMessage();
+      return 0;
+    }
+    if (!OtherPositionals.empty()) {
+      WithColor::error(errs(), ProgramName) << "Unknown command";
+      if (OtherPositionals.size() != 1)
+        errs() << "s";
+      errs() << " ";
+      for (size_t I = 0; I < OtherPositionals.size(); ++I) {
+        if (I)
+          errs() << ", ";
+        errs() << "'" << OtherPositionals[I] << "'";
+      }
+      errs() << ". Run " << ProgramName << " --help for usage.\n";
+    } else {
+      errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
+             << " --help for usage.\n";
+    }
+    return 1;
+  }
+
   if (!validateSubcommandOptions(Args, Subcommand))
     return 1;
 
@@ -3614,22 +3826,22 @@ int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) {
   }
 
   if (Subcommand == "merge") {
-    if (!parseMergeOptions(Args))
+    if (!parseMergeOptions(Args, Positionals))
       return 1;
     return merge_main(ProgramName);
   }
   if (Subcommand == "show") {
-    if (!parseShowOptions(Args))
+    if (!parseShowOptions(Args, Positionals))
       return 1;
     return show_main(ProgramName);
   }
   if (Subcommand == "overlap") {
-    if (!parseOverlapOptions(Args))
+    if (!parseOverlapOptions(Args, Positionals))
       return 1;
     return overlap_main();
   }
   if (Subcommand == "order") {
-    if (!parseOrderOptions(Args))
+    if (!parseOrderOptions(Args, Positionals))
       return 1;
     return order_main();
   }

>From b9e7875655a82eff39eb7ecf76bc4b022d6586e9 Mon Sep 17 00:00:00 2001
From: David Zbarsky <dzbarsky at gmail.com>
Date: Thu, 5 Feb 2026 08:36:59 -0500
Subject: [PATCH 3/3] Adjust tests for new parsing style

---
 bolt/docs/OptimizingClang.md                  |   2 +-
 clang/docs/SourceBasedCodeCoverage.rst        |   4 +-
 clang/docs/UsersManual.rst                    |  10 +-
 clang/test/CodeGenCXX/profile-remap.cpp       |   4 +-
 .../optimization-remark-with-hotness-new-pm.c |   2 +-
 clang/test/Profile/cxx-hash-v2.cpp            |   2 +-
 .../AIX/pgo-lto-bcdtor-function-section.test  |  36 +-
 .../test/profile/ContinuousSyncMode/basic.c   |   2 +-
 .../online-merging-windows.c                  |   4 +-
 .../ContinuousSyncMode/online-merging.c       |   4 +-
 .../runtime-counter-relocation.c              |   2 +-
 .../ContinuousSyncMode/set-file-object.c      |   8 +-
 .../profile/Linux/instrprof-instr-suppl.test  |   8 +-
 .../profile/Linux/instrprof-value-merge-lld.c |   2 +-
 .../profile/Linux/instrprof-value-merge.c     |   6 +-
 .../test/profile/Posix/instrprof-shared.test  |  12 +-
 .../Posix/instrprof-value-prof-shared.test    |  30 +-
 .../profile/Posix/instrprof-visibility.cpp    |   2 +-
 .../Windows/instrprof-multiprocess.test       |   2 +-
 compiler-rt/test/profile/coverage-inline.cpp  |   4 +-
 compiler-rt/test/profile/infinite_loop.c      |   2 +-
 .../profile/instrprof-darwin-dead-strip.c     |   4 +-
 .../test/profile/instrprof-gc-sections.c      |   6 +-
 .../instrprof-no-mmap-during-merging.c        |   4 +-
 compiler-rt/test/profile/instrprof-tmpdir.c   |   6 +-
 .../test/profile/instrprof-value-prof-2.c     |   2 +-
 .../profile/instrprof-value-prof-evict.test   |   6 +-
 .../test/profile/instrprof-value-prof-reset.c |   6 +-
 .../test/profile/instrprof-value-prof.c       |  16 +-
 .../test/profile/instrprof-value-prof.test    |  10 +-
 .../profile/instrprof-write-buffer-internal.c |   4 +-
 compiler-rt/test/profile/runtime_infinite.c   |   2 +-
 llvm/docs/CommandGuide/llvm-profdata.rst      |   2 +-
 llvm/docs/MemProf.rst                         |   2 +-
 llvm/test/CodeGen/X86/fsafdo_probe2.ll        |   2 +-
 llvm/test/CodeGen/X86/fsafdo_test2.ll         |   4 +-
 llvm/test/CodeGen/X86/fsafdo_test3.ll         |   4 +-
 .../PGOProfile/data-access-profile.ll         |   4 +-
 llvm/test/Transforms/PGOProfile/memprof.ll    |   4 +-
 .../memprof_annotate_indirect_call.test       |   4 +-
 .../memprof_max_cold_threshold.test           |   2 +-
 .../Transforms/PGOProfile/suppl-profile.ll    |   8 +-
 .../compressed-profile-symbol-list.ll         |   2 +-
 .../SampleProfile/csspgo-import-list.ll       |   4 +-
 .../Transforms/SampleProfile/csspgo-inline.ll |   2 +-
 .../SampleProfile/csspgo-use-preinliner.ll    |   2 +-
 .../profile-correlation-irreducible-loops.ll  |   2 +-
 .../SampleProfile/profile-format-compress.ll  |   2 +-
 .../SampleProfile/profile-sample-accurate.ll  |   2 +-
 .../SampleProfile/pseudo-probe-inline.ll      |   8 +-
 .../SampleProfile/pseudo-probe-profile.ll     |   2 +-
 .../pseudo-probe-stale-profile-toplev-func.ll |   2 +-
 llvm/test/Transforms/SampleProfile/remap.ll   |   2 +-
 .../SampleProfile/remarks-hotness.ll          |   4 +-
 llvm/test/Transforms/SampleProfile/remarks.ll |   4 +-
 .../uncompressed-profile-symbol-list.ll       |   2 +-
 llvm/test/tools/llvm-cov/Inputs/yaml.makefile |   2 +-
 llvm/test/tools/llvm-cov/mcdc-const.test      |   2 +-
 llvm/test/tools/llvm-cov/mcdc-general.test    |   2 +-
 llvm/test/tools/llvm-profdata/c-general.test  |   4 +-
 llvm/test/tools/llvm-profdata/compat.proftext |  14 +-
 .../llvm-profdata/count-mismatch.proftext     |   4 +-
 .../cs-sample-nested-profile.test             |  20 +-
 .../llvm-profdata/cs-sample-profile.test      |   4 +-
 .../llvm-profdata/cs-sample-trimmer.test      |   8 +-
 .../test/tools/llvm-profdata/csprof-dump.test |  20 +-
 llvm/test/tools/llvm-profdata/cutoff.test     |  12 +-
 .../llvm-profdata/forward-compatible.test     |   8 +-
 .../test/tools/llvm-profdata/general.proftext |  26 +-
 .../llvm-profdata/hash-mismatch.proftext      |   2 +-
 llvm/test/tools/llvm-profdata/help.test       |  14 +-
 llvm/test/tools/llvm-profdata/input-dir.test  |   4 +-
 .../tools/llvm-profdata/input-filenames.test  |   4 +-
 .../tools/llvm-profdata/input-wildcard.test   |   2 +-
 .../test/tools/llvm-profdata/instr-remap.test |   2 +-
 .../tools/llvm-profdata/invalid-profdata.test |   4 +-
 .../malformed-num-counters-zero.test          |  10 +-
 .../test/tools/llvm-profdata/mcdc-bitmap.test |   8 +-
 .../llvm-profdata/memop-size-prof.proftext    |  10 +-
 .../tools/llvm-profdata/memprof-buildid.test  |   4 +-
 .../llvm-profdata/memprof-merge-versions.test |   8 +-
 .../tools/llvm-profdata/memprof-yaml.test     |  12 +-
 .../tools/llvm-profdata/merge-filter.test     |  18 +-
 .../llvm-profdata/merge-incompatible.test     |   2 +-
 .../llvm-profdata/merge-probe-profile.test    |   2 +-
 .../tools/llvm-profdata/merge-traces.proftext |  24 +-
 .../llvm-profdata/merge_empty_profile.test    |   8 +-
 .../tools/llvm-profdata/multiple-inputs.test  |  28 +-
 .../tools/llvm-profdata/overflow-instr.test   |   8 +-
 .../tools/llvm-profdata/overflow-sample.test  |   8 +-
 llvm/test/tools/llvm-profdata/overlap.test    |   8 +-
 llvm/test/tools/llvm-profdata/overlap_cs.test |   4 +-
 llvm/test/tools/llvm-profdata/overlap_vp.test |   4 +-
 .../profile-symbol-list-compress.test         |  16 +-
 .../llvm-profdata/profile-symbol-list.test    |  20 +-
 .../tools/llvm-profdata/pseudo_count.test     |  24 +-
 .../tools/llvm-profdata/raw-32-bits-be.test   |   4 +-
 .../tools/llvm-profdata/raw-32-bits-le.test   |   4 +-
 .../tools/llvm-profdata/raw-64-bits-be.test   |   4 +-
 .../tools/llvm-profdata/raw-64-bits-le.test   |   4 +-
 .../tools/llvm-profdata/raw-two-profiles.test |   2 +-
 .../tools/llvm-profdata/read-traces.proftext  |   8 +-
 .../llvm-profdata/roundtrip-compress.test     |  10 +-
 llvm/test/tools/llvm-profdata/roundtrip.test  |  22 +-
 .../tools/llvm-profdata/same-filename.test    |  16 +-
 .../llvm-profdata/sample-flatten-profile.test |   8 +-
 llvm/test/tools/llvm-profdata/sample-fs.test  |  24 +-
 .../llvm-profdata/sample-hot-func-list.test   |   4 +-
 .../tools/llvm-profdata/sample-overlap.test   |   6 +-
 .../llvm-profdata/sample-profile-basic.test   |   2 +-
 .../llvm-profdata/sample-profile-json.test    |   2 +-
 .../tools/llvm-profdata/sample-remap.test     |   2 +-
 .../llvm-profdata/sample-split-layout.test    |   5 +-
 .../tools/llvm-profdata/sample-summary.test   |   2 +-
 .../tools/llvm-profdata/show-instr-level.test |   4 +-
 .../llvm-profdata/show-order-error.proftext   |   2 +-
 .../tools/llvm-profdata/show-order.proftext   |   2 +-
 .../tools/llvm-profdata/show-prof-info.test   |   4 +-
 .../suppl-instr-with-sample-flatten.test      |   4 +-
 .../suppl-instr-with-sample-static-func.test  |  16 +-
 .../suppl-instr-with-sample.test              |  36 +-
 llvm/test/tools/llvm-profdata/text-dump.test  |  14 +-
 .../llvm-profdata/text-format-errors.test     |   2 +-
 .../tools/llvm-profdata/trace-limit.proftext  |  10 +-
 .../tools/llvm-profdata/value-prof.proftext   |   6 +-
 .../llvm-profdata/vtable-value-prof.test      |   8 +-
 .../tools/llvm-profdata/weight-instr.test     |  28 +-
 .../tools/llvm-profdata/weight-sample.test    |  22 +-
 .../llvm-profgen/afdo-with-vtable-pie.test    |   2 +-
 .../tools/llvm-profgen/afdo-with-vtable.test  |   2 +-
 .../test/tools/llvm-profgen/cs-extbinary.test |   8 +-
 .../test/tools/llvm-profgen/cs-preinline.test |   8 +-
 .../tools/llvm-profgen/inline-cs-noprobe.test |   2 +-
 .../tools/llvm-profgen/inline-noprobe2.test   |   2 +-
 .../llvm-profgen/noinline-cs-noprobe.test     |   6 +-
 llvm/tools/llvm-profdata/Opts.td              | 295 ++++++++--------
 llvm/tools/llvm-profdata/llvm-profdata.cpp    | 318 ++++++------------
 137 files changed, 738 insertions(+), 866 deletions(-)

diff --git a/bolt/docs/OptimizingClang.md b/bolt/docs/OptimizingClang.md
index 9992b4c735c22..a5ce9fdcd134d 100644
--- a/bolt/docs/OptimizingClang.md
+++ b/bolt/docs/OptimizingClang.md
@@ -258,7 +258,7 @@ Once the build is completed, the profile files will be saved under
 passed back into Clang:
 ```bash
 $ cd ${TOPLEV}/stage2-prof-gen/profiles
-$ ${TOPLEV}/stage1/install/bin/llvm-profdata merge -output=clang.profdata *
+$ ${TOPLEV}/stage1/install/bin/llvm-profdata merge --output=clang.profdata *
 ```
 
 ### Building Clang with PGO and LTO
diff --git a/clang/docs/SourceBasedCodeCoverage.rst b/clang/docs/SourceBasedCodeCoverage.rst
index 2f114070a8fb2..453d717dde1ce 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -156,7 +156,7 @@ coverage reports. This is done using the "merge" tool in ``llvm-profdata``
 .. code-block:: console
 
     # Step 3(a): Index the raw profile.
-    % llvm-profdata merge -sparse foo.profraw -o foo.profdata
+    % llvm-profdata merge --sparse foo.profraw -o foo.profdata
 
 For an example of merging multiple profiles created by testing,
 see the LLVM `coverage build script <https://github.com/llvm/llvm-zorg/blob/main/zorg/jenkins/jobs/jobs/llvm-coverage>`_.
@@ -261,7 +261,7 @@ A few final notes:
 
   .. code-block:: console
 
-      % llvm-profdata merge -sparse foo1.profraw foo2.profdata -o foo3.profdata
+      % llvm-profdata merge --sparse foo1.profraw foo2.profdata -o foo3.profdata
 
 Exporting coverage data
 =======================
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c624efb26f67d..c314d61145680 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3239,7 +3239,7 @@ instrumentation:
 
    .. code-block:: console
 
-     $ llvm-profdata merge -output=code.profdata code-*.profraw
+     $ llvm-profdata merge --output=code.profdata code-*.profraw
 
    Note that this step is necessary even when there is only one "raw" profile,
    since the merge operation also changes the file format.
@@ -3284,7 +3284,7 @@ indexed format, regardeless whether it is produced by frontend or the IR pass.
 
   .. code-block:: console
 
-    $ llvm-profdata merge -output=code.profdata yyy/zzz/
+    $ llvm-profdata merge --output=code.profdata yyy/zzz/
 
   If the user wants to turn off the auto-merging feature, or simply override the
   the profile dumping path specified at command line, the environment variable
@@ -3309,7 +3309,7 @@ indexed format, regardeless whether it is produced by frontend or the IR pass.
 
     $ clang++ -O2 -fprofile-generate=yyy/zzz code.cc -o code
     $ ./code
-    $ llvm-profdata merge -output=code.profdata yyy/zzz/
+    $ llvm-profdata merge --output=code.profdata yyy/zzz/
 
   The first few steps are the same as that in ``-fprofile-generate``
   compilation. Then perform a second round of instrumentation.
@@ -3319,7 +3319,7 @@ indexed format, regardeless whether it is produced by frontend or the IR pass.
     $ clang++ -O2 -fprofile-use=code.profdata -fcs-profile-generate=sss/ttt \
       -o cs_code
     $ ./cs_code
-    $ llvm-profdata merge -output=cs_code.profdata sss/ttt code.profdata
+    $ llvm-profdata merge --output=cs_code.profdata sss/ttt code.profdata
 
   The resulted ``cs_code.prodata`` combines ``code.profdata`` and the profile
   generated from binary ``cs_code``. Profile ``cs_code.profata`` can be used by
@@ -3625,7 +3625,7 @@ instrument functions in a specified group. This can be done using the
 
   .. code-block:: console
 
-    $ llvm-profdata merge -output=code.profdata group_*/*.profraw
+    $ llvm-profdata merge --output=code.profdata group_*/*.profraw
 
 
 Profile remapping
diff --git a/clang/test/CodeGenCXX/profile-remap.cpp b/clang/test/CodeGenCXX/profile-remap.cpp
index 748c58d91d105..606930e66ea95 100644
--- a/clang/test/CodeGenCXX/profile-remap.cpp
+++ b/clang/test/CodeGenCXX/profile-remap.cpp
@@ -1,9 +1,9 @@
 // REQUIRES: x86-registered-target
 //
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-sample-use=%S/Inputs/profile-remap.samples -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SAMPLES
-// RUN: llvm-profdata merge -output %t.profdata %S/Inputs/profile-remap.proftext
+// RUN: llvm-profdata merge --output %t.profdata %S/Inputs/profile-remap.proftext
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use=llvm -fprofile-instrument-use-path=%t.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
-// RUN: llvm-profdata merge -output %t.profdata %S/Inputs/profile-remap_entry.proftext
+// RUN: llvm-profdata merge --output %t.profdata %S/Inputs/profile-remap_entry.proftext
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use=llvm -fprofile-instrument-use-path=%t.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
 
 namespace Foo {
diff --git a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
index 0c7e96182aebf..8d6e1c8b49163 100644
--- a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
+++ b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
@@ -9,7 +9,7 @@
 // RUN: llvm-profdata merge \
 // RUN:     %S/Inputs/optimization-remark-with-hotness.proftext \
 // RUN:     -o %t.profdata
-// RUN: llvm-profdata merge -sample \
+// RUN: llvm-profdata merge --sample \
 // RUN:     %S/Inputs/optimization-remark-with-hotness-sample.proftext \
 // RUN:     -o %t-sample.profdata
 //
diff --git a/clang/test/Profile/cxx-hash-v2.cpp b/clang/test/Profile/cxx-hash-v2.cpp
index 53097228ba521..14a51e890ac57 100644
--- a/clang/test/Profile/cxx-hash-v2.cpp
+++ b/clang/test/Profile/cxx-hash-v2.cpp
@@ -1,7 +1,7 @@
 // Check that all of the hashes in this file are unique (i.e, that none of the
 // profiles for these functions are mutually interchangeable).
 //
-// RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes
+// RUN: llvm-profdata show --all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes
 // RUN: uniq %t.hashes > %t.hashes.unique
 // RUN: diff %t.hashes %t.hashes.unique
 
diff --git a/compiler-rt/test/profile/AIX/pgo-lto-bcdtor-function-section.test b/compiler-rt/test/profile/AIX/pgo-lto-bcdtor-function-section.test
index cc351ef4e0acd..95699cec39431 100755
--- a/compiler-rt/test/profile/AIX/pgo-lto-bcdtor-function-section.test
+++ b/compiler-rt/test/profile/AIX/pgo-lto-bcdtor-function-section.test
@@ -16,22 +16,22 @@ int main() { return foo() - 3; }
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 
 // RUN: %clang_pgogen -O2 -c -ffunction-sections foo.c
 // RUN: %clang_pgogen -O2 -c -ffunction-sections main.c
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 
 // ## no PGO at compile step, but PGO at link step.
 // RUN: %clang -O2 -c  foo.c
@@ -39,11 +39,11 @@ int main() { return foo() - 3; }
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 //
 // RUN: %clang_pgogen -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 
 // # LTO, with and without function-sections, and all permutations of -bcdtors
 // ## LTO one file, no PGO at compile, PGO at link
@@ -52,44 +52,44 @@ int main() { return foo() - 3; }
 //
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 //
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 //
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 //
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=NONE
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=NONE
 
 // ## LTO one file, PGO at compile and link
 // RUN: %clang -O2 -c -fno-function-sections foo.c
 // RUN: %clang_pgogen -O2 -c -flto main.c
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=MAIN
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=MAIN
 
 // RUN: %clang -O2 -c -flto foo.c
 // RUN: %clang_pgogen -O2 -c -fno-function-sections main.c
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=MAIN
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=MAIN
 
 // RUN: %clang -O2 -c -flto foo.c
 // RUN: %clang_pgogen -O2 -c -ffunction-sections main.c
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=MAIN
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=MAIN
 
 // RUN: %clang -O2 -c -ffunction-sections foo.c
 // RUN: %clang_pgogen -O2 -c -flto main.c
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=MAIN
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=MAIN
 
 // ## LTO and PGO both files
 // RUN: %clang_pgogen -O2 -c -flto foo.c
@@ -97,19 +97,19 @@ int main() { return foo() - 3; }
 //
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 //
 // RUN: %clang_pgogen -flto -fno-function-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 //
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:all foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 //
 // RUN: %clang_pgogen -flto -ffunction-sections -Wl,-bcdtors:mbr foo.o main.o
 // RUN: rm -f default* && %run ./a.out
-// RUN: llvm-profdata show --all-functions default* | FileCheck  %s -check-prefix=BOTH
+// RUN: llvm-profdata show --all-functions default* | FileCheck  %s --check-prefix=BOTH
 
 // BOTH-DAG: foo:
 // BOTH-DAG: main:
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/basic.c b/compiler-rt/test/profile/ContinuousSyncMode/basic.c
index 209ceec6a83f0..b137de9b0e94b 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/basic.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/basic.c
@@ -3,7 +3,7 @@
 // RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -o %t.exe %s
 // RUN: echo "garbage" > %t.profraw
 // RUN: %run %t.exe
-// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s -check-prefix=CHECK-COUNTS
+// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s --check-prefix=CHECK-COUNTS
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 //
 // COM: The "report" and "show" commands of llvm-cov are not supported on AIX.
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/online-merging-windows.c b/compiler-rt/test/profile/ContinuousSyncMode/online-merging-windows.c
index ffd9676f74958..7716516d5d94a 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/online-merging-windows.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/online-merging-windows.c
@@ -19,7 +19,7 @@
 //
 // RUN: %run %t.dir/main.exe nospawn
 // RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
-// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND1
+// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s --check-prefix=ROUND1
 
 // ROUND1-LABEL: Counters:
 // ROUND1-DAG:   foo:
@@ -39,7 +39,7 @@
 //
 // RUN: %run %t.dir/main.exe spawn
 // RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
-// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND2
+// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s --check-prefix=ROUND2
 
 // ROUND2-LABEL: Counters:
 // ROUND2-DAG:   foo:
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c b/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
index c8b978104e21e..04054cb75d143 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
@@ -18,7 +18,7 @@
 //
 // RUN: %run %t.dir/main.exe nospawn
 // RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
-// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND1
+// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s --check-prefix=ROUND1
 
 // ROUND1-LABEL: Counters:
 // ROUND1-DAG:   dso1:
@@ -42,7 +42,7 @@
 //
 // RUN: %run %t.dir/main.exe spawn 'LLVM_PROFILE_FILE=%t.dir/profdir/%m%c.profraw'
 // RUN: llvm-profdata merge -o %t.profdata %t.dir/profdir
-// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s -check-prefix=ROUND2
+// RUN: llvm-profdata show --counts --all-functions %t.profdata | FileCheck %s --check-prefix=ROUND2
 
 // ROUND2-LABEL: Counters:
 // ROUND2-DAG:   dso1:
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c b/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
index 01b25d2167cc0..b273603c1a96b 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
@@ -3,7 +3,7 @@
 // RUN: %clang_profgen=%t.profraw -fprofile-continuous -fcoverage-mapping -o %t.exe %s
 // RUN: echo "garbage" > %t.profraw
 // RUN: %run %t.exe
-// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s -check-prefix=CHECK-COUNTS
+// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s --check-prefix=CHECK-COUNTS
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 // RUN: %if !target={{.*aix.*}} %{ llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE %}
 
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c b/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c
index 5baa64baaafe3..5ef84af35c7de 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c
@@ -14,15 +14,15 @@
 // RUN: rm -rf %t.dir/profdir/
 // RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%c%mprofraw.old" %run  %t.dir/main.exe merge %t.dir/profdir/profraw.new 'LLVM_PROFILE_FILE=%t.dir/profdir/%c%m.profraw'
 // RUN: llvm-profdata merge -o %t.dir/profdir/profdata %t.dir/profdir/profraw.new
-// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/profdata | FileCheck %s -check-prefix=MERGE
-// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/*profraw.old | FileCheck %s -check-prefix=ZERO
+// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/profdata | FileCheck %s --check-prefix=MERGE
+// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/*profraw.old | FileCheck %s --check-prefix=ZERO
 
 // Test __llvm_profile_set_file_object with mergin enabled and continuous mode disabled.
 // RUN: rm -rf %t.dir/profdir/
 // RUN: env LLVM_PROFILE_FILE="%t.dir/profdir/%mprofraw.old" %run  %t.dir/main.exe merge %t.dir/profdir/profraw.new 'LLVM_PROFILE_FILE=%t.dir/profdir/%m.profraw'
 // RUN: llvm-profdata merge -o %t.dir/profdir/profdata %t.dir/profdir/profraw.new
-// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/profdata | FileCheck %s -check-prefix=MERGE
-// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/*profraw.old | FileCheck %s -check-prefix=ZERO
+// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/profdata | FileCheck %s --check-prefix=MERGE
+// RUN: llvm-profdata show --counts --all-functions %t.dir/profdir/*profraw.old | FileCheck %s --check-prefix=ZERO
 
 // MERGE: Counters:
 // MERGE:   coverage_test:
diff --git a/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test b/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test
index 10650a345ab4b..7f719cfe2111d 100644
--- a/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test
+++ b/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test
@@ -29,15 +29,15 @@
 // RUN: llvm-profdata merge main.profraw -o main.profdata
 
 // The function counters are not scaled up.
-// RUN: llvm-profdata show -all-functions -counts main.profdata | FileCheck %s --check-prefix=INSTR
+// RUN: llvm-profdata show --all-functions --counts main.profdata | FileCheck %s --check-prefix=INSTR
 
 // The instrPGO profile counter of function foo should be scaled up. Note the
 // scaling factor of a function is computed based on instrPGO profiles and
 // invariant to samplePGO profile counters.
-// RUN: llvm-profdata merge -supplement-instr-with-sample=sampleprof.proftext \
-// RUN:               -suppl-min-size-threshold=0 -instr-prof-cold-threshold=1 \
+// RUN: llvm-profdata merge --supplement-instr-with-sample sampleprof.proftext \
+// RUN:               --suppl-min-size-threshold 0 --instr-prof-cold-threshold 1 \
 // RUN:               main.profdata -o merge.profdata
-// RUN: llvm-profdata show -all-functions -counts merge.profdata | FileCheck %s --check-prefix=SUPPL
+// RUN: llvm-profdata show --all-functions --counts merge.profdata | FileCheck %s --check-prefix=SUPPL
 
 // INSTR: Counters:
 // INSTR:   main:
diff --git a/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c b/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c
index b664eb78734de..1e077bc7b3028 100644
--- a/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c
+++ b/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c
@@ -12,4 +12,4 @@
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
-// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
+// RUN: llvm-profdata show --counts --function=main --ic-targets --memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
diff --git a/compiler-rt/test/profile/Linux/instrprof-value-merge.c b/compiler-rt/test/profile/Linux/instrprof-value-merge.c
index dc239e88c676b..571a7f4fab7e3 100644
--- a/compiler-rt/test/profile/Linux/instrprof-value-merge.c
+++ b/compiler-rt/test/profile/Linux/instrprof-value-merge.c
@@ -7,7 +7,7 @@
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
-// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
+// RUN: llvm-profdata show --counts --function=main --ic-targets --memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
 
 /// -z start-stop-gc requires binutils 2.37. Don't test the option for now.
 /// TODO: Add -Wl,--gc-sections.
@@ -18,7 +18,7 @@
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
-// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
+// RUN: llvm-profdata show --counts --function=main --ic-targets --memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
 
 // RUN: %clang_pgogen -o %t -O3 %S/Inputs/instrprof-value-merge.c -no-pie -fuse-ld=gold -ffunction-sections -fdata-sections
 // RUN: rm -rf %t.profdir
@@ -27,4 +27,4 @@
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
-// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
+// RUN: llvm-profdata show --counts --function=main --ic-targets --memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c
diff --git a/compiler-rt/test/profile/Posix/instrprof-shared.test b/compiler-rt/test/profile/Posix/instrprof-shared.test
index 7087fa2fa33ed..250635fd6be40 100644
--- a/compiler-rt/test/profile/Posix/instrprof-shared.test
+++ b/compiler-rt/test/profile/Posix/instrprof-shared.test
@@ -50,12 +50,12 @@ RUN: not llvm-profdata merge -o %t-no-instr1-no-instr1.profdata %t-no-instr1-no-
 RUN: not llvm-profdata merge -o %t-no-instr2-no-instr1.profdata %t-no-instr2-no-instr1.profraw 2>&1 | FileCheck %s --check-prefix=MISSING-FILE
 MISSING-FILE: profraw
 
-RUN: llvm-profdata show -counts --function main %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-main-1
-RUN: llvm-profdata show -counts --function main %t-instr-no-instr1.profdata | grep -v 'Total\|Maximum' > %t-main-2
-RUN: llvm-profdata show -counts --function main %t-instr-no-instr2.profdata | grep -v 'Total\|Maximum' > %t-main-3
-RUN: llvm-profdata show -counts --function foo %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-1
-RUN: llvm-profdata show -counts --function foo %t-no-instr1-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-2
-RUN: llvm-profdata show -counts --function foo %t-no-instr2-instr.profdata | grep -v 'Total\|Maximum'  > %t-foo-3
+RUN: llvm-profdata show --counts --function main %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-main-1
+RUN: llvm-profdata show --counts --function main %t-instr-no-instr1.profdata | grep -v 'Total\|Maximum' > %t-main-2
+RUN: llvm-profdata show --counts --function main %t-instr-no-instr2.profdata | grep -v 'Total\|Maximum' > %t-main-3
+RUN: llvm-profdata show --counts --function foo %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-1
+RUN: llvm-profdata show --counts --function foo %t-no-instr1-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-2
+RUN: llvm-profdata show --counts --function foo %t-no-instr2-instr.profdata | grep -v 'Total\|Maximum'  > %t-foo-3
 
 RUN: %clang_profuse=%t-instr-instr.profdata -o %t-main-instr-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-main.c
 RUN: %clang_profuse=%t-instr-no-instr1.profdata -o %t-main-instr-no-instr1.ll -S -emit-llvm %S/../Inputs/instrprof-shared-main.c
diff --git a/compiler-rt/test/profile/Posix/instrprof-value-prof-shared.test b/compiler-rt/test/profile/Posix/instrprof-value-prof-shared.test
index 34abe82952a23..844f5a09b3053 100644
--- a/compiler-rt/test/profile/Posix/instrprof-value-prof-shared.test
+++ b/compiler-rt/test/profile/Posix/instrprof-value-prof-shared.test
@@ -3,8 +3,8 @@
 // RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t -rpath %t.d %t.d/t.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255  %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
 
 // IR level instrumentation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.shared -DSHARED_LIB  %S/../Inputs/instrprof-value-prof-real.c
@@ -12,9 +12,9 @@
 // Profile data from shared library will be concatenated to the same raw file.
 // RUN: env LLVM_PROFILE_FILE=%t.ir.profraw  LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir
 // RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.profdata -o %t.ir.proftxt 
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.profdata -o %t.ir.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
 // RUN: FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt
 
 // Same as above but with profile online merging enabled.
@@ -23,11 +23,11 @@
 // RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.m.shared -DSHARED_LIB  %S/../Inputs/instrprof-value-prof-real.c
 // RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.m %t.d/t.ir.m.shared -DCALL_SHARED  %S/../Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.m
-// RUN: llvm-profdata merge -o %t.ir.m.profdata -dump-input-file-list %t.prof/ | count 2
+// RUN: llvm-profdata merge -o %t.ir.m.profdata --dump-input-file-list %t.prof/ | count 2
 // RUN: llvm-profdata merge -o %t.ir.m.profdata  %t.prof/
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.m.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.m.profdata -o %t.ir.m.proftxt 
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.m.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.m.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.m.profdata -o %t.ir.m.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.m.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
 // RUN: FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.m.proftxt
 
 
@@ -36,9 +36,9 @@
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.dyn %t.d/t.ir.dyn.shared -DCALL_SHARED  %S/../Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn
 // RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.dyn.profdata -o %t.ir.dyn.proftxt 
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.dyn.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.dyn.profdata -o %t.ir.dyn.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.dyn.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
 // RUN: FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt
 
 // IR level instrumentation: main program uses static counter, shared library uses dynamic memory alloc.
@@ -46,7 +46,7 @@
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.mixed %t.d/t.ir.dyn.shared -DCALL_SHARED  %S/../Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.mixed.profraw  LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.mixed
 // RUN: llvm-profdata merge -o %t.ir.mixed.profdata %t.ir.mixed.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.mixed.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.mixed.profdata -o %t.ir.mixed.proftxt 
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.mixed.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.mixed.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.mixed.profdata -o %t.ir.mixed.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.mixed.profdata | FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED
 // RUN: FileCheck  %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.mixed.proftxt
diff --git a/compiler-rt/test/profile/Posix/instrprof-visibility.cpp b/compiler-rt/test/profile/Posix/instrprof-visibility.cpp
index 016aaed57e151..5499f1e12fa08 100644
--- a/compiler-rt/test/profile/Posix/instrprof-visibility.cpp
+++ b/compiler-rt/test/profile/Posix/instrprof-visibility.cpp
@@ -2,7 +2,7 @@
 // RUN: %clangxx_profgen -fcoverage-mapping %S/Inputs/instrprof-visibility-helper.cpp -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge %t.profraw -o %t.profdata
-// RUN: llvm-profdata show --all-functions %t.profraw | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFILE
+// RUN: llvm-profdata show --all-functions %t.profraw | FileCheck --allow-deprecated-dag-overlap %s --check-prefix=PROFILE
 // RUN: llvm-cov show %t -instr-profile=%t.profdata | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=COV
 
 namespace {
diff --git a/compiler-rt/test/profile/Windows/instrprof-multiprocess.test b/compiler-rt/test/profile/Windows/instrprof-multiprocess.test
index ae5ebd45bec95..1f4dadc1cefd7 100644
--- a/compiler-rt/test/profile/Windows/instrprof-multiprocess.test
+++ b/compiler-rt/test/profile/Windows/instrprof-multiprocess.test
@@ -1,7 +1,7 @@
 RUN: %clang_profgen %S/Inputs/instrprof-multiprocess.c -o %t
 RUN: rm -f %t_*.profraw
 RUN: env LLVM_PROFILE_FILE=%t_%m.profraw %run %t
-RUN: llvm-profdata show --counts -function=foo %t_*.profraw | FileCheck %s
+RUN: llvm-profdata show --counts --function=foo %t_*.profraw | FileCheck %s
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/compiler-rt/test/profile/coverage-inline.cpp b/compiler-rt/test/profile/coverage-inline.cpp
index a4114363007a3..c47bca79247a1 100644
--- a/compiler-rt/test/profile/coverage-inline.cpp
+++ b/compiler-rt/test/profile/coverage-inline.cpp
@@ -5,7 +5,7 @@
 // RUN: %clang_profgen -g -fcoverage-mapping -c -o %t2.o %s
 // RUN: %clang_profgen -g -fcoverage-mapping %t1.o %t2.o -o %t.exe
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
-// RUN: llvm-profdata show %t.profraw -all-functions | FileCheck %s
+// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
 
 // Again, with optimizations and inlining. This tests that we use comdats
 // correctly.
@@ -13,7 +13,7 @@
 // RUN: %clang_profgen -O2 -g -fcoverage-mapping -c -o %t2.o %s
 // RUN: %clang_profgen -g -fcoverage-mapping %t1.o %t2.o -o %t.exe
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
-// RUN: llvm-profdata show %t.profraw -all-functions | FileCheck %s
+// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
 
 // CHECK:  {{.*}}foo{{.*}}:
 // CHECK-NEXT:    Hash:
diff --git a/compiler-rt/test/profile/infinite_loop.c b/compiler-rt/test/profile/infinite_loop.c
index 0e3981c712f6b..dd323b46e5d1c 100644
--- a/compiler-rt/test/profile/infinite_loop.c
+++ b/compiler-rt/test/profile/infinite_loop.c
@@ -1,6 +1,6 @@
 // RUN: %clang_pgogen  -O2 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
-// RUN: llvm-profdata show -function main -counts  %t.profraw| FileCheck  %s 
+// RUN: llvm-profdata show --function main --counts  %t.profraw| FileCheck  %s
 
 void exit(int);
 int g;
diff --git a/compiler-rt/test/profile/instrprof-darwin-dead-strip.c b/compiler-rt/test/profile/instrprof-darwin-dead-strip.c
index 7f3b48ba74808..230bcef1706e3 100644
--- a/compiler-rt/test/profile/instrprof-darwin-dead-strip.c
+++ b/compiler-rt/test/profile/instrprof-darwin-dead-strip.c
@@ -5,7 +5,7 @@
 // RUN:   -Wl,-sectalign,__DATA,__llvm_prf_cnts,0x1000 -Wl,-sectalign,__DATA,__llvm_prf_data,0x1000 -Wl,-sectalign,__DATA,__llvm_prf_bits,0x1000 -o %t %s
 // RUN: %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s -check-prefix=PROF
+// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s --check-prefix=PROF
 // RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s -check-prefix=COV
 // RUN: nm %t | FileCheck %s -check-prefix=NM
 // RUN: otool -V -s __DATA __llvm_prf_names %t | FileCheck %s -check-prefix=PRF_NAMES
@@ -15,7 +15,7 @@
 // RUN:   -Wl,-sectalign,__DATA,__llvm_prf_cnts,0x1000 -Wl,-sectalign,__DATA,__llvm_prf_data,0x1000 -Wl,-sectalign,__DATA,__llvm_prf_bits,0x1000 -o %t.lto %s
 // RUN: %run %t.lto
 // RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw
-// RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s -check-prefix=PROF
+// RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s --check-prefix=PROF
 // RUN: llvm-cov show %t.lto -instr-profile %t.lto.profdata | FileCheck %s -check-prefix=COV
 // RUN: nm %t.lto | FileCheck %s -check-prefix=NM
 // RUN: otool -V -s __DATA __llvm_prf_names %t.lto | FileCheck %s -check-prefix=PRF_NAMES
diff --git a/compiler-rt/test/profile/instrprof-gc-sections.c b/compiler-rt/test/profile/instrprof-gc-sections.c
index 6541ee7387e30..84a18bd5c7d5b 100644
--- a/compiler-rt/test/profile/instrprof-gc-sections.c
+++ b/compiler-rt/test/profile/instrprof-gc-sections.c
@@ -8,7 +8,7 @@
 // RUN: %clang_profgen=%t.profraw -fuse-ld=lld -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -o %t %s
 // RUN: %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s -check-prefix=PROF
+// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s --check-prefix=PROF
 // RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s -check-prefix=COV
 // RUN: llvm-nm %t | FileCheck %s -check-prefix=NM
 // RUN: llvm-readelf -x __llvm_prf_names %t | FileCheck %s -check-prefix=PRF_NAMES
@@ -18,7 +18,7 @@
 // RUN: %clang_lto_profgen=%t.lto.profraw -fuse-ld=lld -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -flto -o %t.lto %s
 // RUN: %run %t.lto
 // RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw
-// RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s -check-prefix=PROF
+// RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s --check-prefix=PROF
 // RUN: llvm-cov show %t.lto -instr-profile %t.lto.profdata | FileCheck %s -check-prefix=COV
 // RUN: llvm-nm %t.lto | FileCheck %s -check-prefix=NM
 // RUN: llvm-readelf -x __llvm_prf_names %t.lto | FileCheck %s -check-prefix=PRF_NAMES
@@ -37,7 +37,7 @@
 // RUN: %clang_pgogen=%t.pgo.profraw -fuse-ld=lld -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -o %t.pgo %s
 // RUN: %run %t.pgo
 // RUN: llvm-profdata merge -o %t.pgo.profdata %t.pgo.profraw
-// RUN: llvm-profdata show --all-functions %t.pgo.profdata | FileCheck %s -check-prefix=PGO
+// RUN: llvm-profdata show --all-functions %t.pgo.profdata | FileCheck %s --check-prefix=PGO
 // RUN: llvm-nm %t.pgo | FileCheck %s -check-prefix=NM
 
 #ifdef CODE
diff --git a/compiler-rt/test/profile/instrprof-no-mmap-during-merging.c b/compiler-rt/test/profile/instrprof-no-mmap-during-merging.c
index 0f269388388d8..90be6a193e312 100644
--- a/compiler-rt/test/profile/instrprof-no-mmap-during-merging.c
+++ b/compiler-rt/test/profile/instrprof-no-mmap-during-merging.c
@@ -5,9 +5,9 @@
 // Need to run a.out twice. On the second time, a merge will occur, which will
 // trigger an mmap.
 // RUN: ./a.out
-// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s -check-prefix=PROFDATA
+// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s --check-prefix=PROFDATA
 // RUN: env LLVM_PROFILE_NO_MMAP=1 LLVM_PROFILE_VERBOSE=1 ./a.out 2>&1 | FileCheck %s
-// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s -check-prefix=PROFDATA2
+// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s --check-prefix=PROFDATA2
 
 // CHECK: could not use mmap; using fread instead
 // PROFDATA: Block counts: [1]
diff --git a/compiler-rt/test/profile/instrprof-tmpdir.c b/compiler-rt/test/profile/instrprof-tmpdir.c
index 9d4b3d35e94e7..1fb60c9f360a9 100644
--- a/compiler-rt/test/profile/instrprof-tmpdir.c
+++ b/compiler-rt/test/profile/instrprof-tmpdir.c
@@ -10,15 +10,15 @@
 //
 // Check that a dir separator is appended after %t is subsituted.
 // RUN: env TMPDIR="%t" LLVM_PROFILE_FILE="%%traw1.profraw" %run %t/binary
-// RUN: llvm-profdata show ./raw1.profraw | FileCheck %s -check-prefix TMPDIR
+// RUN: llvm-profdata show ./raw1.profraw | FileCheck %s --check-prefix TMPDIR
 //
 // Check that substitution works even if a redundant dir separator is added.
 // RUN: env TMPDIR="%t" LLVM_PROFILE_FILE="%%t/raw2.profraw" %run %t/binary
-// RUN: llvm-profdata show ./raw2.profraw | FileCheck %s -check-prefix TMPDIR
+// RUN: llvm-profdata show ./raw2.profraw | FileCheck %s --check-prefix TMPDIR
 //
 // Check that we fall back to the default path if TMPDIR is missing.
 // RUN: env -u TMPDIR LLVM_PROFILE_FILE="%%t/raw3.profraw" %run %t/binary 2>&1 | FileCheck %s -check-prefix MISSING
-// RUN: llvm-profdata show ./default.profraw | FileCheck %s -check-prefix TMPDIR
+// RUN: llvm-profdata show ./default.profraw | FileCheck %s --check-prefix TMPDIR
 
 // TMPDIR: Maximum function count: 1
 
diff --git a/compiler-rt/test/profile/instrprof-value-prof-2.c b/compiler-rt/test/profile/instrprof-value-prof-2.c
index abc990ac8b052..a3646ff77b007 100644
--- a/compiler-rt/test/profile/instrprof-value-prof-2.c
+++ b/compiler-rt/test/profile/instrprof-value-prof-2.c
@@ -1,7 +1,7 @@
 // RUN: %clang_profgen -mllvm -enable-value-profiling -O2 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata > %t.out
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata > %t.out
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-1 < %t.out
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-2 < %t.out
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-3 < %t.out
diff --git a/compiler-rt/test/profile/instrprof-value-prof-evict.test b/compiler-rt/test/profile/instrprof-value-prof-evict.test
index 8b054fb24371e..bfab4fe53babf 100644
--- a/compiler-rt/test/profile/instrprof-value-prof-evict.test
+++ b/compiler-rt/test/profile/instrprof-value-prof-evict.test
@@ -1,16 +1,16 @@
 // RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=10 -o %t %S/Inputs/instrprof-value-prof-evict.c
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
 
 // IR level instrumentation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true  -mllvm -vp-counters-per-site=10 -o %t.ir  %S/Inputs/instrprof-value-prof-evict.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.profraw %run %t.ir
 // RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
 
 // IR level instrumentation, dynamic allocation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -o %t.ir.dyn  %S/Inputs/instrprof-value-prof-evict.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn
 // RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.dyn.profdata | FileCheck  %S/Inputs/instrprof-value-prof-evict.c
diff --git a/compiler-rt/test/profile/instrprof-value-prof-reset.c b/compiler-rt/test/profile/instrprof-value-prof-reset.c
index b3744f5735066..e8bb0b317c1bc 100644
--- a/compiler-rt/test/profile/instrprof-value-prof-reset.c
+++ b/compiler-rt/test/profile/instrprof-value-prof-reset.c
@@ -1,19 +1,19 @@
 // RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=3 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck %s
 
 // IR level instrumentation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true  -mllvm -vp-counters-per-site=3 -o %t.ir  %s
 // RUN: env LLVM_PROFILE_FILE=%t.ir.profraw %run %t.ir
 // RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.profdata | FileCheck  %s
 
 // IR level instrumentation, dynamic allocation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -o %t.ir.dyn  %s
 // RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn
 // RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.dyn.profdata | FileCheck  %s
 void callee_0() {}
 void callee_1() {}
 void callee_2() {}
diff --git a/compiler-rt/test/profile/instrprof-value-prof.c b/compiler-rt/test/profile/instrprof-value-prof.c
index 3e8203f8182d1..1a4a614a5c1a4 100644
--- a/compiler-rt/test/profile/instrprof-value-prof.c
+++ b/compiler-rt/test/profile/instrprof-value-prof.c
@@ -4,9 +4,9 @@
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 // RUN: llvm-profdata merge -o %t-2.profdata %t-2.profraw
 // RUN: llvm-profdata merge -o %t-merged.profdata %t.profraw %t-2.profdata
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-2.profdata | FileCheck  %s -check-prefix=NO-VALUE
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck  %s
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-merged.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-2.profdata | FileCheck  %s --check-prefix=NO-VALUE
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-merged.profdata | FileCheck  %s
 //
 // RUN: env LLVM_PROFILE_FILE=%t-3.profraw LLVM_VP_BUFFER_SIZE=1 %run %t
 // RUN: env LLVM_PROFILE_FILE=%t-4.profraw LLVM_VP_BUFFER_SIZE=8 %run %t
@@ -18,11 +18,11 @@
 // RUN: llvm-profdata merge -o %t-5.profdata %t-5.profraw
 // RUN: llvm-profdata merge -o %t-6.profdata %t-6.profraw
 // RUN: llvm-profdata merge -o %t-7.profdata %t-7.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-3.profdata | FileCheck  %s
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-4.profdata | FileCheck  %s
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-5.profdata | FileCheck  %s
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-6.profdata | FileCheck  %s
-// RUN: llvm-profdata show --all-functions -ic-targets  %t-7.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-3.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-4.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-5.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-6.profdata | FileCheck  %s
+// RUN: llvm-profdata show --all-functions --ic-targets  %t-7.profdata | FileCheck  %s
 
 #include <stdint.h>
 #include <stdio.h>
diff --git a/compiler-rt/test/profile/instrprof-value-prof.test b/compiler-rt/test/profile/instrprof-value-prof.test
index f85c131e6e4b8..f0e15ed7d4c63 100644
--- a/compiler-rt/test/profile/instrprof-value-prof.test
+++ b/compiler-rt/test/profile/instrprof-value-prof.test
@@ -2,21 +2,21 @@
 // RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t %S/Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
 
 // IR level instrumentation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t.ir  %S/Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir
 // RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.profdata -o %t.ir.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.profdata -o %t.ir.proftxt 
 // RUN: FileCheck  %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt
 
 // IR level instrumentation with dynamic memory allocation
 // RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -o %t.ir.dyn  %S/Inputs/instrprof-value-prof-real.c
 // RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn
 // RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw
-// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
-// RUN: llvm-profdata merge -text  %t.ir.dyn.profdata -o %t.ir.dyn.proftxt 
+// RUN: llvm-profdata show --all-functions --ic-targets  %t.ir.dyn.profdata | FileCheck  %S/Inputs/instrprof-value-prof-real.c
+// RUN: llvm-profdata merge --text  %t.ir.dyn.profdata -o %t.ir.dyn.proftxt 
 // RUN: FileCheck  %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt
 
diff --git a/compiler-rt/test/profile/instrprof-write-buffer-internal.c b/compiler-rt/test/profile/instrprof-write-buffer-internal.c
index 2c1c29ac0c588..319a14f96a504 100644
--- a/compiler-rt/test/profile/instrprof-write-buffer-internal.c
+++ b/compiler-rt/test/profile/instrprof-write-buffer-internal.c
@@ -5,8 +5,8 @@
 // RUN: rm -f %t.buf.profraw %t.profraw
 // RUN: %clang_profgen -w -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t %t.buf.profraw
-// RUN: llvm-profdata show %t.buf.profraw | FileCheck %s -check-prefix=WRITE-BUFFER
-// RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s -check-prefix=ALREADY-DUMPED
+// RUN: llvm-profdata show %t.buf.profraw | FileCheck %s --check-prefix=WRITE-BUFFER
+// RUN: not llvm-profdata show %t.profraw 2>&1 | FileCheck %s --check-prefix=ALREADY-DUMPED
 
 // WRITE-BUFFER: Instrumentation level: Front-end
 // WRITE-BUFFER: Total functions: 1
diff --git a/compiler-rt/test/profile/runtime_infinite.c b/compiler-rt/test/profile/runtime_infinite.c
index b55f5e2750dd9..6058dd5f1475f 100644
--- a/compiler-rt/test/profile/runtime_infinite.c
+++ b/compiler-rt/test/profile/runtime_infinite.c
@@ -6,7 +6,7 @@
 
 // RUN: %clang_pgogen -mllvm -do-counter-promotion=false -O2 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
-// RUN: llvm-profdata show -function main -counts  %t.profraw| FileCheck  %s
+// RUN: llvm-profdata show --function main --counts  %t.profraw| FileCheck  %s
 void exit(int);
 
 int __llvm_profile_dump(void);
diff --git a/llvm/docs/CommandGuide/llvm-profdata.rst b/llvm/docs/CommandGuide/llvm-profdata.rst
index 0b1cd02e2230f..8b1dc412444e7 100644
--- a/llvm/docs/CommandGuide/llvm-profdata.rst
+++ b/llvm/docs/CommandGuide/llvm-profdata.rst
@@ -260,7 +260,7 @@ Merge three profiles:
 
 ::
 
-    llvm-profdata merge foo.profdata bar.profdata baz.profdata -output merged.profdata
+    llvm-profdata merge foo.profdata bar.profdata baz.profdata --output merged.profdata
 
 Weighted Input
 ++++++++++++++
diff --git a/llvm/docs/MemProf.rst b/llvm/docs/MemProf.rst
index 16b7a08174866..012fdf1e7c5b8 100644
--- a/llvm/docs/MemProf.rst
+++ b/llvm/docs/MemProf.rst
@@ -41,7 +41,7 @@ To enable MemProf instrumentation, compile your application with the ``-fmemory-
 
 .. note::
     Link with ``-fmemory-profile`` as well to link the necessary runtime libraries. If you use a separate link step, ensure the flag is passed to the linker.
-    On Linux, the flags ``-fno-pie -no-pie -Wl,-z,noseparate-code -Wl,--build-id`` are currently required to ensure the binary layout (executable segment at offset 0) and Build ID presence are compatible with the ``llvm-profdata`` profile reader.
+    On Linux, the flags ``-fno-pie --no-pie -Wl,-z,noseparate-code -Wl,--build-id`` are currently required to ensure the binary layout (executable segment at offset 0) and Build ID presence are compatible with the ``llvm-profdata`` profile reader.
 
 Running and Generating Profiles
 -------------------------------
diff --git a/llvm/test/CodeGen/X86/fsafdo_probe2.ll b/llvm/test/CodeGen/X86/fsafdo_probe2.ll
index 04e4145abdc0c..618019cf49aff 100644
--- a/llvm/test/CodeGen/X86/fsafdo_probe2.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_probe2.ll
@@ -1,5 +1,5 @@
 ; REQUIRES: asserts
-; RUN: llvm-profdata merge --sample -profile-isfs --extbinary -o %t.afdo %S/Inputs/fsloader-probe.afdo
+; RUN: llvm-profdata merge --sample --profile-isfs --extbinary -o %t.afdo %S/Inputs/fsloader-probe.afdo
 ; RUN: llc -enable-fs-discriminator -fs-profile-file=%t.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefix=LOADER
 ;
 ;;
diff --git a/llvm/test/CodeGen/X86/fsafdo_test2.ll b/llvm/test/CodeGen/X86/fsafdo_test2.ll
index fc4c1e87dd285..3a1648d349a86 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test2.ll
@@ -1,9 +1,9 @@
 ; REQUIRES: asserts
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=false < %s | FileCheck %s --check-prefixes=V0,V01
-; RUN: llvm-profdata merge --sample -profile-isfs -o %t0.afdo %S/Inputs/fsloader.afdo
+; RUN: llvm-profdata merge --sample --profile-isfs -o %t0.afdo %S/Inputs/fsloader.afdo
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=false -fs-profile-file=%t0.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=LOADERV0,LOADER
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true < %s | FileCheck %s --check-prefixes=V1,V01
-; RUN: llvm-profdata merge --sample -profile-isfs -o %t1.afdo %S/Inputs/fsloader_v1.afdo
+; RUN: llvm-profdata merge --sample --profile-isfs -o %t1.afdo %S/Inputs/fsloader_v1.afdo
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%t1.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=LOADERV1,LOADER
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%S/Inputs/fsloader_v1.afdo -profile-isfs -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=LOADERV1,LOADER
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%S/Inputs/fsloader_v1.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=NOLOAD
diff --git a/llvm/test/CodeGen/X86/fsafdo_test3.ll b/llvm/test/CodeGen/X86/fsafdo_test3.ll
index 79b57fe4f1a32..e14f2d0761e86 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test3.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test3.ll
@@ -1,6 +1,6 @@
-; RUN: llvm-profdata merge --sample -profile-isfs -o %t0.afdo %S/Inputs/fsloader.afdo
+; RUN: llvm-profdata merge --sample --profile-isfs -o %t0.afdo %S/Inputs/fsloader.afdo
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=false -fs-profile-file=%t0.afdo -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false -print-machine-bfi -print-bfi-func-name=foo -print-before=fs-profile-loader -stop-after=fs-profile-loader < %s 2>&1 | FileCheck %s --check-prefixes=BFI,BFIV0
-; RUN: llvm-profdata merge --sample -profile-isfs -o %t1.afdo %S/Inputs/fsloader_v1.afdo
+; RUN: llvm-profdata merge --sample --profile-isfs -o %t1.afdo %S/Inputs/fsloader_v1.afdo
 ; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%t1.afdo -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false -print-machine-bfi -print-bfi-func-name=foo -print-before=fs-profile-loader -stop-after=fs-profile-loader < %s 2>&1 | FileCheck %s --check-prefixes=BFI,BFIV1
 ;
 ;;
diff --git a/llvm/test/Transforms/PGOProfile/data-access-profile.ll b/llvm/test/Transforms/PGOProfile/data-access-profile.ll
index 205184bdd7156..d83b37947e86a 100644
--- a/llvm/test/Transforms/PGOProfile/data-access-profile.ll
+++ b/llvm/test/Transforms/PGOProfile/data-access-profile.ll
@@ -4,8 +4,8 @@
 ; RUN: rm -rf %t && split-file %s %t && cd %t
 
 ;; Read text profiles and merge them into indexed profiles.
-; RUN: llvm-profdata merge --memprof-version=4 memprof.yaml -o memprof.profdata
-; RUN: llvm-profdata merge --memprof-version=4 memprof-no-dap.yaml -o memprof-no-dap.profdata
+; RUN: llvm-profdata merge --memprof-version 4 memprof.yaml -o memprof.profdata
+; RUN: llvm-profdata merge --memprof-version 4 memprof-no-dap.yaml -o memprof-no-dap.profdata
 
 ;; Run optimizer pass on an IR module without IR functions, and test that global
 ;; variables in the module could be annotated (i.e., no early return),
diff --git a/llvm/test/Transforms/PGOProfile/memprof.ll b/llvm/test/Transforms/PGOProfile/memprof.ll
index a1f0f1d403c8f..63fa2ec5907f9 100644
--- a/llvm/test/Transforms/PGOProfile/memprof.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof.ll
@@ -91,14 +91,14 @@
 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL
 
 ;; Make sure we emit a random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
+; RUN: llvm-profdata merge --memprof-random-hotness %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
 ; RAND: random hotness seed =
 ;; Can't check the exact values, but make sure applying the random profile
 ;; succeeds with the same stats
 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
 
 ;; Make sure we use a specific random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
+; RUN: llvm-profdata merge --memprof-random-hotness --memprof-random-hotness-seed 1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
 ; RAND2: random hotness seed = 1730170724
 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
 
diff --git a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
index 4677eebff3cfe..f1cfdf23e2754 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
+++ b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
@@ -1,12 +1,12 @@
 ; RUN: split-file %s %t
 
 ;; Basic functionality with flag toggle
-; RUN: llvm-profdata merge --memprof-version=4 %t/basic.yaml -o %t/basic.memprofdata
+; RUN: llvm-profdata merge --memprof-version 4 %t/basic.yaml -o %t/basic.memprofdata
 ; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=false -S 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLE
 ; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-ENABLE --dump-input-filter=all
 
 ;; FDO conflict handling
-; RUN: llvm-profdata merge --memprof-version=4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata
+; RUN: llvm-profdata merge --memprof-version 4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata
 ; RUN: opt < %t/fdo_conflict.ll -passes='memprof-use<profile-filename=%t/fdo_conflict.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-FDO
 
 ;--- basic.yaml
diff --git a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
index 8f1cabf9a4e87..2d803bae363ca 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
+++ b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
@@ -6,7 +6,7 @@
 ; RUN: split-file %s %t
 
 ;; Specify version 4 so that a summary is generated.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof_max_cold_threshold.yaml -o %t/memprof_max_cold_threshold.memprofdata
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof_max_cold_threshold.yaml -o %t/memprof_max_cold_threshold.memprofdata
 
 ; RUN: llvm-profdata show --memory %t/memprof_max_cold_threshold.memprofdata | FileCheck %s --check-prefixes=SUMMARY
 ; SUMMARY: # MemProfSummary:
diff --git a/llvm/test/Transforms/PGOProfile/suppl-profile.ll b/llvm/test/Transforms/PGOProfile/suppl-profile.ll
index 9e00ceec92b99..175b565ef06e3 100644
--- a/llvm/test/Transforms/PGOProfile/suppl-profile.ll
+++ b/llvm/test/Transforms/PGOProfile/suppl-profile.ll
@@ -1,13 +1,13 @@
 ; Supplement instr profile suppl-profile.proftext with sample profile
 ; sample-profile.proftext.
 ; For hot functions:
-; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \
-; RUN:   -supplement-instr-with-sample=%p/Inputs/sample-profile-hot.proftext \
+; RUN: llvm-profdata merge --instr --suppl-min-size-threshold 0 \
+; RUN:   --supplement-instr-with-sample %p/Inputs/sample-profile-hot.proftext \
 ; RUN:   %S/Inputs/suppl-profile.proftext -o %t.profdata
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=HOT
 ; For warm functions:
-; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \
-; RUN:   -supplement-instr-with-sample=%p/Inputs/sample-profile-warm.proftext \
+; RUN: llvm-profdata merge --instr --suppl-min-size-threshold 0 \
+; RUN:   --supplement-instr-with-sample %p/Inputs/sample-profile-warm.proftext \
 ; RUN:   %S/Inputs/suppl-profile.proftext -o %t1.profdata
 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t1.profdata -S | FileCheck %s --check-prefix=WARM
 
diff --git a/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll b/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll
index 016016fc5063e..2bdce84f36467 100644
--- a/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll
+++ b/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll
@@ -1,4 +1,4 @@
 ; REQUIRES: zlib
 ; Append inline.prof with profile symbol list and save it after compression.
-; RUN: llvm-profdata merge --sample --prof-sym-list=%S/Inputs/profile-symbol-list.text --compress-all-sections=true --extbinary %S/Inputs/inline.prof --output=%t.profdata
+; RUN: llvm-profdata merge --sample --prof-sym-list %S/Inputs/profile-symbol-list.text --compress-all-sections --extbinary %S/Inputs/inline.prof -o %t.profdata
 ; RUN: opt < %S/Inputs/profile-symbol-list.ll -passes=sample-profile -profile-accurate-for-symsinlist -sample-profile-file=%t.profdata -S | FileCheck %S/Inputs/profile-symbol-list.ll
diff --git a/llvm/test/Transforms/SampleProfile/csspgo-import-list.ll b/llvm/test/Transforms/SampleProfile/csspgo-import-list.ll
index ade2d73fb4684..35a529856f20e 100644
--- a/llvm/test/Transforms/SampleProfile/csspgo-import-list.ll
+++ b/llvm/test/Transforms/SampleProfile/csspgo-import-list.ll
@@ -2,10 +2,10 @@
 ; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list.prof --sample-profile-even-flow-distribution=0 -S | FileCheck %s
 ; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/csspgo-import-list.prof -o %t.prof
 ; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%t.prof --sample-profile-even-flow-distribution=0 -S | FileCheck %s
-; RUN: llvm-profdata show --sample -show-sec-info-only %t.prof | FileCheck %s --check-prefix=CHECK-ORDERED
+; RUN: llvm-profdata show --sample --show-sec-info-only %t.prof | FileCheck %s --check-prefix=CHECK-ORDERED
 ; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/csspgo-import-list.prof -o %t.md5
 ; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%t.md5 --sample-profile-even-flow-distribution=0 -S | FileCheck %s
-; RUN: llvm-profdata show --sample -show-sec-info-only %t.md5 | FileCheck %s --check-prefix=CHECK-ORDERED
+; RUN: llvm-profdata show --sample --show-sec-info-only %t.md5 | FileCheck %s --check-prefix=CHECK-ORDERED
 
 ;; Validate that with replay in effect, we import call sites even if they are below the threshold
 ;; Baseline import decisions
diff --git a/llvm/test/Transforms/SampleProfile/csspgo-inline.ll b/llvm/test/Transforms/SampleProfile/csspgo-inline.ll
index deabc275d99c9..8b5f6db0d3ff0 100644
--- a/llvm/test/Transforms/SampleProfile/csspgo-inline.ll
+++ b/llvm/test/Transforms/SampleProfile/csspgo-inline.ll
@@ -10,7 +10,7 @@
 ; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/profile-context-tracker.prof -o %t.md5
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.md5 -sample-profile-inline-size -sample-profile-prioritized-inline=0 -profile-sample-accurate -S -pass-remarks=inline -o /dev/null 2>&1 | FileCheck %s --check-prefix=INLINE-BASE
 
-; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout=nest  %S/Inputs/profile-context-tracker.prof -o %t.prof
+; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout nest %S/Inputs/profile-context-tracker.prof -o %t.prof
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -sample-profile-inline-size -sample-profile-prioritized-inline=0 -profile-sample-accurate -S -pass-remarks=inline -o /dev/null 2>&1 | FileCheck %s --check-prefix=INLINE-BASE
 
 ; With new FDO early inliner, callee entry count is used to drive inlining instead of callee total samples, so we get less inlining for given profile
diff --git a/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll b/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll
index e4ee93970d6f7..f197d255e499d 100644
--- a/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll
+++ b/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll
@@ -3,7 +3,7 @@
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE
 
-; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout=nest  -generate-merged-base-profiles=0 %S/Inputs/csspgo-use-preinliner.prof -o %t.prof
+; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout nest %S/Inputs/csspgo-use-preinliner.prof -o %t.prof
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE
 
diff --git a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
index ef2fcc6a9e248..7ee030b42cbc9 100644
--- a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
+++ b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 | opt -passes='print<block-freq>' -disable-output  -use-iterative-bfi-inference 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 | opt -passes='print<block-freq>' -disable-output -use-iterative-bfi-inference 2>&1 | FileCheck %s
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 -S | FileCheck %s --check-prefix=CHECK2
 ; RUN: opt < %s -passes='print<block-freq>' -use-iterative-bfi-inference -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK3
 
diff --git a/llvm/test/Transforms/SampleProfile/profile-format-compress.ll b/llvm/test/Transforms/SampleProfile/profile-format-compress.ll
index 112da585d90b3..28f9280123259 100644
--- a/llvm/test/Transforms/SampleProfile/profile-format-compress.ll
+++ b/llvm/test/Transforms/SampleProfile/profile-format-compress.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: zlib
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline.prof -S | FileCheck %s
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections %S/Inputs/inline.prof -o %t.compress.extbinary.afdo
+; RUN: llvm-profdata merge --sample --extbinary --compress-all-sections %S/Inputs/inline.prof -o %t.compress.extbinary.afdo
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.compress.extbinary.afdo -S | FileCheck %s
 
 ; Original C++ test case
diff --git a/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll b/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll
index 71defe66395cb..2cf113a61dae3 100644
--- a/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll
+++ b/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll
@@ -1,6 +1,6 @@
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profsampleacc.extbinary.afdo -profile-summary-cutoff-hot=900000 -profile-sample-accurate -S | FileCheck %s --check-prefix=CALL_SUM_IS_HOT
 
-; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo
+; RUN: llvm-profdata merge --sample --extbinary --prof-sym-list %S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-summary-cutoff-hot=600000 -profile-accurate-for-symsinlist -S | FileCheck %s --check-prefix=PROFSYMLIST
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=2 -S | FileCheck %s --check-prefix=PSLCUTOFF2
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=3 -S | FileCheck %s --check-prefix=PSLCUTOFF3
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
index b4083f26d9912..7b427ddfa345c 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
@@ -1,14 +1,14 @@
-; RUN: opt < %s -passes=pseudo-probe,sample-profile  -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile  -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t.opt.yaml
 
 ; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/pseudo-probe-inline.prof -o %t2
-; RUN: opt < %s -passes=pseudo-probe,sample-profile  -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t2.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile  -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t2.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t2.opt.yaml
 
-; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t3.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t3.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t3.opt.yaml
 
-; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t4.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t4.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t4.opt.yaml
 
 @factor = dso_local global i32 3, align 4
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
index 66dbc49a1d210..ed98fd1697935 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml -sample-profile-use-profi=0 -S -o %t
+; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml -sample-profile-use-profi=0 -S -o %t
 ; RUN: FileCheck %s --input-file %t
 ; RUN: FileCheck %s -check-prefix=YAML --input-file %t.opt.yaml
 ; RUN: opt < %t -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -sample-profile-remove-probe -S | FileCheck %s -check-prefix=REMOVE-PROBE
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll
index 15a19477f7509..1c6d8501d317a 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll
@@ -1,6 +1,6 @@
 ; REQUIRES: asserts && x86-registered-target
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-toplev-func.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-TEXT
-; RUN: llvm-profdata merge --sample %S/Inputs/pseudo-probe-stale-profile-toplev-func.prof -extbinary -o %t.extbinary
+; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/pseudo-probe-stale-profile-toplev-func.prof -o %t.extbinary
 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.extbinary --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-EXTBIN
 
 ; CHECK-TEXT: Run stale profile matching for main
diff --git a/llvm/test/Transforms/SampleProfile/remap.ll b/llvm/test/Transforms/SampleProfile/remap.ll
index ffb57e23a735c..c883e6c517e81 100644
--- a/llvm/test/Transforms/SampleProfile/remap.ll
+++ b/llvm/test/Transforms/SampleProfile/remap.ll
@@ -1,7 +1,7 @@
 ; RUN: opt %s -passes=sample-profile -sample-profile-file=%S/Inputs/remap.prof -sample-profile-remapping-file=%S/Inputs/remap.map | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
 ;
 ; Check whether profile remapping work with loading profile on demand used by extbinary format profile.
-; RUN: llvm-profdata merge -sample -extbinary %S/Inputs/remap.prof -o %t.extbinary.afdo
+; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/remap.prof -o %t.extbinary.afdo
 ; RUN: opt %s -passes=sample-profile -sample-profile-file=%t.extbinary.afdo -sample-profile-remapping-file=%S/Inputs/remap.map | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
 ;
 ; Reduced from branch.ll
diff --git a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
index 36fb3c5818170..4b544cab578e1 100644
--- a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
+++ b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -4,7 +4,7 @@
 ; RUN: rm -f %t.yaml %t.hot.yaml
 ; RUN: opt %s --passes='sample-profile,cgscc(inline)' \
 ; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
-; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output %t.yaml \
 ; RUN: -pass-remarks-with-hotness --disable-output
 ; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml
 ; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml
@@ -12,7 +12,7 @@
 ;; test 'auto' threshold
 ; RUN: opt %s --passes='sample-profile,cgscc(inline)' \
 ; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
-; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output %t.hot.yaml \
 ; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output
 ; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml
 ; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml
diff --git a/llvm/test/Transforms/SampleProfile/remarks.ll b/llvm/test/Transforms/SampleProfile/remarks.ll
index decf4b1aadbd9..493afafa2ed06 100644
--- a/llvm/test/Transforms/SampleProfile/remarks.ll
+++ b/llvm/test/Transforms/SampleProfile/remarks.ll
@@ -1,7 +1,7 @@
-; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t.opt.yaml
 
-; RUN: opt < %s -passes=sample-profile -annotate-sample-profile-inline-phase -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=sample-profile -annotate-sample-profile-inline-phase -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s
 ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t.opt.yaml
 
 ; Original test case.
diff --git a/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll b/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll
index 66bd22522fe8c..47b373b0ffbb9 100644
--- a/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll
+++ b/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll
@@ -1,3 +1,3 @@
 ; Append inline.prof with profile symbol list and save it without compression.
-; RUN: llvm-profdata merge --sample --prof-sym-list=%S/Inputs/profile-symbol-list.text --compress-all-sections=false --extbinary %S/Inputs/inline.prof --output=%t.profdata
+; RUN: llvm-profdata merge --sample --prof-sym-list %S/Inputs/profile-symbol-list.text --extbinary %S/Inputs/inline.prof -o %t.profdata
 ; RUN: opt < %S/Inputs/profile-symbol-list.ll -passes=sample-profile -profile-accurate-for-symsinlist -sample-profile-file=%t.profdata -S | FileCheck %S/Inputs/profile-symbol-list.ll
diff --git a/llvm/test/tools/llvm-cov/Inputs/yaml.makefile b/llvm/test/tools/llvm-cov/Inputs/yaml.makefile
index 2a256f0cffc0b..d99ce794bc520 100644
--- a/llvm/test/tools/llvm-cov/Inputs/yaml.makefile
+++ b/llvm/test/tools/llvm-cov/Inputs/yaml.makefile
@@ -84,7 +84,7 @@ ARGS_mcdc-const-folding := \
 	    eval "./$< $$cmd"; \
 	  done; \
 	fi
-	find -name '$*.*.profraw' | xargs llvm-profdata merge --sparse -o $@
+	find --name '$*.*.profraw' | xargs llvm-profdata merge --sparse -o $@
 
 %.proftext: %.profdata
 	llvm-profdata merge --text -o $@ $<
diff --git a/llvm/test/tools/llvm-cov/mcdc-const.test b/llvm/test/tools/llvm-cov/mcdc-const.test
index 76eb7cf706d73..ffdb2c4dbdce7 100644
--- a/llvm/test/tools/llvm-cov/mcdc-const.test
+++ b/llvm/test/tools/llvm-cov/mcdc-const.test
@@ -223,6 +223,6 @@ for x in mcdc-const mcdc-const-folding; do (
     ./$x 1 1
     ./$x 1 1 # Redundant
   fi
-  llvm-profdata merge --sparse -o $x.profdata $(find -name '*.profraw')
+  llvm-profdata merge --sparse -o $x.profdata $(find --name '*.profraw')
   llvm-profdata merge --text -o $x.proftext $x.profdata
 ); done
diff --git a/llvm/test/tools/llvm-cov/mcdc-general.test b/llvm/test/tools/llvm-cov/mcdc-general.test
index 1835af9a4c6b5..b46be8a135ee1 100644
--- a/llvm/test/tools/llvm-cov/mcdc-general.test
+++ b/llvm/test/tools/llvm-cov/mcdc-general.test
@@ -153,6 +153,6 @@ for x in mcdc-general; do
   clang++ -fprofile-instr-generate $x.o -o $x
   find -name '*.profraw' | xargs rm -f
   ./$x
-  llvm-profdata merge --sparse -o $x.profdata $(find -name '*.profraw')
+  llvm-profdata merge --sparse -o $x.profdata $(find --name '*.profraw')
   llvm-profdata merge --text -o $x.proftext $x.profdata
 done
diff --git a/llvm/test/tools/llvm-profdata/c-general.test b/llvm/test/tools/llvm-profdata/c-general.test
index ab4849fac034f..c17059a7239b6 100644
--- a/llvm/test/tools/llvm-profdata/c-general.test
+++ b/llvm/test/tools/llvm-profdata/c-general.test
@@ -9,8 +9,8 @@ $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/c-general.c -mllvm -enabl
 $ LLVM_PROFILE_FILE=$TESTDIR/Inputs/c-general.profraw ./a.out
 
 RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - | FileCheck %s
-RUN: llvm-profdata show %p/Inputs/c-general.profraw --topn=3 -o - | FileCheck %s --check-prefix=TOPN
-RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function=switches | FileCheck %s -check-prefixes=SWITCHES,CHECK
+RUN: llvm-profdata show %p/Inputs/c-general.profraw --topn 3 -o - | FileCheck %s --check-prefix=TOPN
+RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function switches | FileCheck %s --check-prefixes=SWITCHES,CHECK
 
 SWITCHES-LABEL: Counters:
 SWITCHES-NEXT:   switches:
diff --git a/llvm/test/tools/llvm-profdata/compat.proftext b/llvm/test/tools/llvm-profdata/compat.proftext
index 111fd41988197..42741a451c3d9 100644
--- a/llvm/test/tools/llvm-profdata/compat.proftext
+++ b/llvm/test/tools/llvm-profdata/compat.proftext
@@ -5,7 +5,7 @@
 # The input file at %S/Inputs/compat.profdata.v1 was generated with
 # llvm-profdata merge from r214548.
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function function_count_only --counts | FileCheck %s -check-prefix=FUNC_COUNT_ONLY
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function function_count_only --counts | FileCheck %s --check-prefix=FUNC_COUNT_ONLY
 function_count_only
 0
 1
@@ -15,7 +15,7 @@ function_count_only
 # FUNC_COUNT_ONLY-NEXT: Function count: 97531
 # FUNC_COUNT_ONLY-NEXT: Block counts: []
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function "name with spaces" --counts | FileCheck %s -check-prefix=SPACES
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function "name with spaces" --counts | FileCheck %s --check-prefix=SPACES
 name with spaces
 1024
 2
@@ -26,7 +26,7 @@ name with spaces
 # SPACES-NEXT: Function count: 0
 # SPACES-NEXT: Block counts: [0]
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function large_numbers --counts | FileCheck %s -check-prefix=LARGENUM
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 --function large_numbers --counts | FileCheck %s --check-prefix=LARGENUM
 large_numbers
 4611686018427387903
 6
@@ -41,12 +41,12 @@ large_numbers
 # LARGENUM-NEXT: Function count: 2305843009213693952
 # LARGENUM-NEXT: Block counts: [1152921504606846976, 576460752303423488, 288230376151711744, 144115188075855872, 72057594037927936]
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 | FileCheck %s -check-prefix=SUMMARY
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v1 | FileCheck %s --check-prefix=SUMMARY
 # SUMMARY: Total functions: 3
 # SUMMARY: Maximum function count: 2305843009213693952
 # SUMMARY: Maximum internal block count: 1152921504606846976
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v2 -all-functions --counts | FileCheck %s -check-prefix=FORMATV2
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v2 --all-functions --counts | FileCheck %s --check-prefix=FORMATV2
 
 # FORMATV2: Counters:
 # FORMATV2-NEXT:   foo:
@@ -65,7 +65,7 @@ large_numbers
 # FORMATV2-NEXT: Maximum function count: 499500
 # FORMATV2-NEXT: Maximum internal block count: 1000000
 #
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v4 -all-functions --counts | FileCheck %s -check-prefix=FORMATV4
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v4 --all-functions --counts | FileCheck %s --check-prefix=FORMATV4
 
 # FORMATV4: Counters:
 # FORMATV4:   name with spaces:
@@ -88,7 +88,7 @@ large_numbers
 # FORMATV4: Maximum function count: 2305843009213693952
 # FORMATV4: Maximum internal block count: 1152921504606846976
 
-# RUN: llvm-profdata show %S/Inputs/compat.profdata.v10 -all-functions --counts | FileCheck %s -check-prefix=FORMATV10
+# RUN: llvm-profdata show %S/Inputs/compat.profdata.v10 --all-functions --counts | FileCheck %s --check-prefix=FORMATV10
 
 # FORMATV10: Counters:
 # FORMATV10:   large_numbers:
diff --git a/llvm/test/tools/llvm-profdata/count-mismatch.proftext b/llvm/test/tools/llvm-profdata/count-mismatch.proftext
index c4ac2f7866d19..872d629bfa940 100644
--- a/llvm/test/tools/llvm-profdata/count-mismatch.proftext
+++ b/llvm/test/tools/llvm-profdata/count-mismatch.proftext
@@ -1,8 +1,8 @@
 # Make sure we don't try to combine counters with the same function
 # name and a matching hash if the number of counters differs
 
-# RUN: llvm-profdata merge %s -o %t.profdata 2>&1 | FileCheck -check-prefix=MERGE_ERRS %s
-# RUN: llvm-profdata show %t.profdata -all-functions -counts > %t.out
+# RUN: llvm-profdata merge %s -o %t.profdata 2>&1 | FileCheck --check-prefix=MERGE_ERRS %s
+# RUN: llvm-profdata show %t.profdata --all-functions --counts > %t.out
 # RUN: FileCheck %s -input-file %t.out
 foo
 1024
diff --git a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
index d2b07cf05fd24..b54a51c4f3180 100644
--- a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
+++ b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
@@ -1,17 +1,17 @@
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest  -generate-merged-base-profiles=0
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest
 RUN: FileCheck %s < %t.proftext --match-full-lines --strict-whitespace
-RUN: llvm-profdata merge --sample --text -output=%t.probe.proftext %S/Inputs/cs-sample-preinline-probe.proftext --convert-sample-profile-layout=nest  -generate-merged-base-profiles=0
+RUN: llvm-profdata merge --sample --text -o %t.probe.proftext %S/Inputs/cs-sample-preinline-probe.proftext --convert-sample-profile-layout nest
 RUN: FileCheck %s < %t.probe.proftext --match-full-lines --strict-whitespace -check-prefix=PROBE
-RUN: llvm-profdata merge --sample --extbinary -output=%t.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest  -generate-merged-base-profiles=0
-RUN: llvm-profdata merge --sample --text -output=%t2.proftext %t.profbin
+RUN: llvm-profdata merge --sample --extbinary -o %t.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest
+RUN: llvm-profdata merge --sample --text -o %t2.proftext %t.profbin
 RUN: FileCheck %s < %t2.proftext --match-full-lines --strict-whitespace
-RUN: llvm-profdata show --sample -show-sec-info-only %t.profbin | FileCheck %s -check-prefix=PREINLINE
-RUN: llvm-profdata merge --sample --text -output=%t3.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest  -generate-merged-base-profiles=1
+RUN: llvm-profdata show --sample --show-sec-info-only %t.profbin | FileCheck %s --check-prefix=PREINLINE
+RUN: llvm-profdata merge --sample --text -o %t3.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest --generate-merged-base-profiles
 RUN: FileCheck %s < %t3.proftext --match-full-lines --strict-whitespace -check-prefix=RECOUNT
-RUN: llvm-profdata merge --sample --extbinary -output=%t2.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest  -generate-merged-base-profiles=1
-RUN: llvm-profdata show -sample -detailed-summary %S/Inputs/cs-sample-preinline.proftext | FileCheck %s -check-prefix=SUMMARY
-RUN: llvm-profdata show -sample -detailed-summary %t2.profbin | FileCheck %s -check-prefix=SUMMARY-NEST
-RUN: llvm-profdata show -sample -detailed-summary %t3.proftext | FileCheck %s -check-prefix=SUMMARY-NEST
+RUN: llvm-profdata merge --sample --extbinary -o %t2.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest --generate-merged-base-profiles
+RUN: llvm-profdata show --sample --detailed-summary %S/Inputs/cs-sample-preinline.proftext | FileCheck %s --check-prefix=SUMMARY
+RUN: llvm-profdata show --sample --detailed-summary %t2.profbin | FileCheck %s --check-prefix=SUMMARY-NEST
+RUN: llvm-profdata show --sample --detailed-summary %t3.proftext | FileCheck %s --check-prefix=SUMMARY-NEST
 
 
 ; CHECK:main:1968621:12
diff --git a/llvm/test/tools/llvm-profdata/cs-sample-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-profile.test
index ce69a1ffd61a6..9d90807664492 100644
--- a/llvm/test/tools/llvm-profdata/cs-sample-profile.test
+++ b/llvm/test/tools/llvm-profdata/cs-sample-profile.test
@@ -1,6 +1,6 @@
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample.proftext
 RUN: diff -b %t.proftext %S/Inputs/cs-sample.proftext
 RUN: llvm-profdata merge --sample --extbinary %p/Inputs/cs-sample.proftext -o %t.prof && llvm-profdata merge --sample --text %t.prof -o %t1.proftext
 RUN: diff -b %t1.proftext %S/Inputs/cs-sample.proftext
-RUN: llvm-profdata show --sample -show-sec-info-only %t.prof | FileCheck %s
+RUN: llvm-profdata show --sample --show-sec-info-only %t.prof | FileCheck %s
 CHECK: FunctionMetadata {{.*}} Flags: {attr}
diff --git a/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test b/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test
index a25c89d96d7f8..0b8cc30b4b809 100644
--- a/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test
+++ b/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test
@@ -1,11 +1,11 @@
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample.proftext
 RUN: diff -b %t.proftext %S/Inputs/cs-sample.proftext
 
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -profile-summary-cold-count=500
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample.proftext --sample-merge-cold-context --profile-summary-cold-count 500
 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-MERGE
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cold-count=500
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample.proftext --sample-merge-cold-context --sample-trim-cold-context --profile-summary-cold-count 500
 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-END
-RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cutoff-cold=990000
+RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample.proftext --sample-merge-cold-context --sample-trim-cold-context --profile-summary-cutoff-cold 990000
 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-END
 
 CHECK-TRIM:      [main:3 @ _Z5funcAi:1 @ _Z8funcLeafi]:1467299:11
diff --git a/llvm/test/tools/llvm-profdata/csprof-dump.test b/llvm/test/tools/llvm-profdata/csprof-dump.test
index a03b9d8a003e1..01d7769f1a814 100644
--- a/llvm/test/tools/llvm-profdata/csprof-dump.test
+++ b/llvm/test/tools/llvm-profdata/csprof-dump.test
@@ -1,8 +1,8 @@
-Basic test for option -showcs:
-RUN: llvm-profdata show %p/Inputs/cs.proftext | FileCheck  %s -check-prefix=ZEROSUMMARY
-RUN: llvm-profdata show %p/Inputs/noncs.proftext | FileCheck  %s -check-prefix=SUMMARY
-RUN: llvm-profdata show -showcs %p/Inputs/cs.proftext | FileCheck  %s -check-prefix=SUMMARY
-RUN: llvm-profdata show -showcs %p/Inputs/noncs.proftext | FileCheck  %s -check-prefix=ZEROSUMMARY
+Basic test for option --showcs:
+RUN: llvm-profdata show %p/Inputs/cs.proftext | FileCheck  %s --check-prefix=ZEROSUMMARY
+RUN: llvm-profdata show %p/Inputs/noncs.proftext | FileCheck  %s --check-prefix=SUMMARY
+RUN: llvm-profdata show --showcs %p/Inputs/cs.proftext | FileCheck  %s --check-prefix=SUMMARY
+RUN: llvm-profdata show --showcs %p/Inputs/noncs.proftext | FileCheck  %s --check-prefix=ZEROSUMMARY
 ZEROSUMMARY: Instrumentation level: IR
 ZEROSUMMARY: Total functions: 0
 ZEROSUMMARY: Maximum function count: 0
@@ -15,17 +15,17 @@ SUMMARY: Maximum internal block count: 62
 Basic tests for context sensitive profile dump functions:
 RUN: llvm-profdata merge -o %t-combined.profdata %p/Inputs/cs.proftext %p/Inputs/noncs.proftext
 
-RUN: llvm-profdata show --all-functions -counts -showcs %p/Inputs/cs.proftext > %t-text.csdump
-RUN: llvm-profdata show --all-functions -counts -showcs %t-combined.profdata > %t-index.csdump
+RUN: llvm-profdata show --all-functions --counts --showcs %p/Inputs/cs.proftext > %t-text.csdump
+RUN: llvm-profdata show --all-functions --counts --showcs %t-combined.profdata > %t-index.csdump
 RUN: diff %t-text.csdump %t-index.csdump
 
-RUN: llvm-profdata show --all-functions -counts %p/Inputs/noncs.proftext > %t-text.noncsdump
-RUN: llvm-profdata show --all-functions -counts %t-combined.profdata > %t-index.noncsdump
+RUN: llvm-profdata show --all-functions --counts %p/Inputs/noncs.proftext > %t-text.noncsdump
+RUN: llvm-profdata show --all-functions --counts %t-combined.profdata > %t-index.noncsdump
 RUN: diff %t-text.noncsdump %t-index.noncsdump
 
 Roundtrip test:
 
 RUN: llvm-profdata merge -o %t.0.profdata %S/Inputs/CSIR_profile.proftext
-RUN: llvm-profdata merge -text -o %t.0.proftext %t.0.profdata
+RUN: llvm-profdata merge --text -o %t.0.proftext %t.0.profdata
 RUN: diff -b %t.0.proftext %S/Inputs/CSIR_profile.proftext
 
diff --git a/llvm/test/tools/llvm-profdata/cutoff.test b/llvm/test/tools/llvm-profdata/cutoff.test
index 9d59ede4e8428..2ed38ad4a5f67 100644
--- a/llvm/test/tools/llvm-profdata/cutoff.test
+++ b/llvm/test/tools/llvm-profdata/cutoff.test
@@ -1,11 +1,11 @@
 Basic tests for cutoff options in show command.
 
-RUN: llvm-profdata show -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1,CHECK
-RUN: llvm-profdata show -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000,CHECK
-RUN: llvm-profdata show -all-functions -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1FUNC,CUTOFF1,CHECK
-RUN: llvm-profdata show -all-functions -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000FUNC,CUTOFF1000,CHECK
-RUN: llvm-profdata show -value-cutoff=1 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1,CUTOFF1,CHECK
-RUN: llvm-profdata show -value-cutoff=1000 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1000,CUTOFF1000,CHECK
+RUN: llvm-profdata show --value-cutoff 1 %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=CUTOFF1,CHECK
+RUN: llvm-profdata show --value-cutoff 1000 %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=CUTOFF1000,CHECK
+RUN: llvm-profdata show --all-functions --value-cutoff 1 %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=CUTOFF1FUNC,CUTOFF1,CHECK
+RUN: llvm-profdata show --all-functions --value-cutoff 1000 %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=CUTOFF1000FUNC,CUTOFF1000,CHECK
+RUN: llvm-profdata show --value-cutoff 1 --list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=BELOW1,CUTOFF1,CHECK
+RUN: llvm-profdata show --value-cutoff 1000 --list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s --check-prefixes=BELOW1000,CUTOFF1000,CHECK
 CUTOFF1FUNC-NOT: bar
 CUTOFF1FUNC: Functions shown: 2
 CUTOFF1000FUNC-NOT: bar
diff --git a/llvm/test/tools/llvm-profdata/forward-compatible.test b/llvm/test/tools/llvm-profdata/forward-compatible.test
index 51a7336bb4056..5f3886c8e7611 100644
--- a/llvm/test/tools/llvm-profdata/forward-compatible.test
+++ b/llvm/test/tools/llvm-profdata/forward-compatible.test
@@ -1,8 +1,8 @@
 REQUIRES: zlib
-RUN: llvm-profdata show -sample %S/Inputs/unknown.section.extbin.profdata | FileCheck %s
-RUN: llvm-profdata show -sample %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s
-RUN: llvm-profdata show -sample -show-sec-info-only %S/Inputs/unknown.section.extbin.profdata | FileCheck %s -check-prefix=HDR
-RUN: llvm-profdata show -sample -show-sec-info-only %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s -check-prefix=HDR-COMPRESS
+RUN: llvm-profdata show --sample %S/Inputs/unknown.section.extbin.profdata | FileCheck %s
+RUN: llvm-profdata show --sample %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s
+RUN: llvm-profdata show --sample --show-sec-info-only %S/Inputs/unknown.section.extbin.profdata | FileCheck %s --check-prefix=HDR
+RUN: llvm-profdata show --sample --show-sec-info-only %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s --check-prefix=HDR-COMPRESS
 
 # The input unknown.section.extbin.profdata contains an unknown section type
 # which uses an enum value which won't be used in the near future. Check
diff --git a/llvm/test/tools/llvm-profdata/general.proftext b/llvm/test/tools/llvm-profdata/general.proftext
index 89762f2540f6a..0d42594c4160f 100644
--- a/llvm/test/tools/llvm-profdata/general.proftext
+++ b/llvm/test/tools/llvm-profdata/general.proftext
@@ -1,8 +1,8 @@
-# RUN: llvm-profdata merge -sparse=true %s -o %t.profdata
+# RUN: llvm-profdata merge --sparse %s -o %t.profdata
 
-# RUN: llvm-profdata merge -sparse=false %s -o %t.profdata.dense
+# RUN: llvm-profdata merge %s -o %t.profdata.dense
 
-# RUN: llvm-profdata show %t.profdata --function function_count_only --counts | FileCheck %s -check-prefix=FUNC_COUNT_ONLY
+# RUN: llvm-profdata show %t.profdata --function function_count_only --counts | FileCheck %s --check-prefix=FUNC_COUNT_ONLY
 function_count_only
 0
 1
@@ -12,7 +12,7 @@ function_count_only
 # FUNC_COUNT_ONLY-NEXT: Function count: 97531
 # FUNC_COUNT_ONLY-NEXT: Block counts: []
 
-# RUN: llvm-profdata show %t.profdata.dense --function "name with spaces" --counts | FileCheck %s -check-prefix=SPACES
+# RUN: llvm-profdata show %t.profdata.dense --function "name with spaces" --counts | FileCheck %s --check-prefix=SPACES
 # RUN: llvm-profdata show %t.profdata --function "name with spaces" --counts | FileCheck %s --check-prefix=SPARSE_SPACES
 name with spaces
 1024
@@ -25,7 +25,7 @@ name with spaces
 # SPACES-NEXT: Block counts: [0]
 # SPARSE_SPACES-NOT: Function count: 0
 
-# RUN: llvm-profdata show %t.profdata --function large_numbers --counts | FileCheck %s -check-prefix=LARGENUM
+# RUN: llvm-profdata show %t.profdata --function large_numbers --counts | FileCheck %s --check-prefix=LARGENUM
 large_numbers
 4611686018427387903
 6
@@ -40,7 +40,7 @@ large_numbers
 # LARGENUM-NEXT: Function count: 2305843009213693952
 # LARGENUM-NEXT: Block counts: [1152921504606846976, 576460752303423488, 288230376151711744, 144115188075855872, 72057594037927936]
 
-# RUN: llvm-profdata show %t.profdata.dense --function hex_hash | FileCheck %s -check-prefix=HEX-HASH
+# RUN: llvm-profdata show %t.profdata.dense --function hex_hash | FileCheck %s --check-prefix=HEX-HASH
 hex_hash
 0x1234
 1
@@ -48,26 +48,26 @@ hex_hash
 # HEX-HASH: Hash: 0x0000000000001234
 # HEX-HASH-NEXT: Counters: 1
 
-# RUN: llvm-profdata show %t.profdata --function NOSUCHFUNC | FileCheck %s -check-prefix=NOSUCHFUNC
+# RUN: llvm-profdata show %t.profdata --function NOSUCHFUNC | FileCheck %s --check-prefix=NOSUCHFUNC
 # NOSUCHFUNC-NOT: Counters:
 # NOSUCHFUNC: Functions shown: 0
 
-# RUN: llvm-profdata show %t.profdata --function _ | FileCheck %s -check-prefix=SOMEFUNCS
-# RUN: llvm-profdata show %t.profdata.dense --function _ | FileCheck %s -check-prefix=SOMEFUNCS_DENSE
+# RUN: llvm-profdata show %t.profdata --function _ | FileCheck %s --check-prefix=SOMEFUNCS
+# RUN: llvm-profdata show %t.profdata.dense --function _ | FileCheck %s --check-prefix=SOMEFUNCS_DENSE
 # SOMEFUNCS: Counters:
 # SOMEFUNCS-DAG: large_numbers:
 # SOMEFUNCS-DAG: function_count_only:
 # SOMEFUNCS: Functions shown: 2
 # SOMEFUNCS_DENSE: Functions shown: 3
 
-# RUN: llvm-profdata show %t.profdata.dense | FileCheck %s -check-prefix=SUMMARY
+# RUN: llvm-profdata show %t.profdata.dense | FileCheck %s --check-prefix=SUMMARY
 # SUMMARY-NOT: Counters:
 # SUMMARY-NOT: Functions shown:
 # SUMMARY: Total functions: 4
 # SUMMARY: Maximum function count: 2305843009213693952
 # SUMMARY: Maximum internal block count: 1152921504606846976
 
-# RUN: llvm-profdata show --detailed-summary %t.profdata.dense | FileCheck %s -check-prefix=DETAILED-SUMMARY
+# RUN: llvm-profdata show --detailed-summary %t.profdata.dense | FileCheck %s --check-prefix=DETAILED-SUMMARY
 # DETAILED-SUMMARY: Total number of blocks: 10
 # DETAILED-SUMMARY: Total count: 4539628424389557499
 # DETAILED-SUMMARY: Detailed summary:
@@ -79,10 +79,10 @@ hex_hash
 # DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.99% of the total counts.
 # DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.999% of the total counts.
 
-# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-2
+# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs 600000 %t.profdata | FileCheck %s --check-prefix=DETAILED-SUMMARY-2
 # DETAILED-SUMMARY-2: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts.
 #
-# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000,900000,999999 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-3
+# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs 600000,900000,999999 %t.profdata | FileCheck %s --check-prefix=DETAILED-SUMMARY-3
 # DETAILED-SUMMARY-3: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts.
 # DETAILED-SUMMARY-3: 4 blocks (57.14%) with count >= 288230376151711744 account for 90% of the total counts.
 # DETAILED-SUMMARY-3: 6 blocks (85.71%) with count >= 72057594037927936 account for 99.9999% of the total counts.
diff --git a/llvm/test/tools/llvm-profdata/hash-mismatch.proftext b/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
index 24908e288d6b4..15abd7f7760f1 100644
--- a/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
+++ b/llvm/test/tools/llvm-profdata/hash-mismatch.proftext
@@ -2,7 +2,7 @@
 # sure we keep both.
 
 # RUN: llvm-profdata merge %s -o %t 2>&1
-# RUN: llvm-profdata show %t -all-functions -counts > %t.out
+# RUN: llvm-profdata show %t --all-functions --counts > %t.out
 
 # The function ordering is non-deterministic, so we need to do our
 # checks in multiple runs.
diff --git a/llvm/test/tools/llvm-profdata/help.test b/llvm/test/tools/llvm-profdata/help.test
index b1b1c6da8dd72..b1b3673591e45 100644
--- a/llvm/test/tools/llvm-profdata/help.test
+++ b/llvm/test/tools/llvm-profdata/help.test
@@ -5,18 +5,18 @@
 # TOP: OVERVIEW: LLVM profile data
 # TOP: USAGE: llvm-profdata [subcommand] [options]
 # TOP: SUBCOMMANDS:
-# TOP: merge - Takes several profiles and merge them together.
-# TOP: show - Takes a profile data file and displays the profiles.
+# TOP-DAG: merge - Takes several profiles and merge them together.
+# TOP-DAG: show - Takes a profile data file and displays the profiles.
 
 # MERGE: OVERVIEW: LLVM profile data
 # MERGE: Takes several profiles and merge them together.
 # MERGE: OPTIONS:
-# MERGE: -instr
-# MERGE: -output <output>
-# MERGE: -sample
+# MERGE-DAG: --instr
+# MERGE-DAG: --output <output>
+# MERGE-DAG: --sample
 
 # SHOW: OVERVIEW: LLVM profile data
 # SHOW: Takes a profile data file and displays the profiles.
 # SHOW: OPTIONS:
-# SHOW: -output <output>
-# SHOW: -show-format
+# SHOW-DAG: --output <output>
+# SHOW-DAG: --show-format
diff --git a/llvm/test/tools/llvm-profdata/input-dir.test b/llvm/test/tools/llvm-profdata/input-dir.test
index 93918c1c8892d..f90eebf120231 100644
--- a/llvm/test/tools/llvm-profdata/input-dir.test
+++ b/llvm/test/tools/llvm-profdata/input-dir.test
@@ -12,8 +12,8 @@ RUN: echo ' ' > %t.dir2/bar
 RUN: echo ' ' > %t.dir2/foo
 RUN: echo ' ' > %t.dir2/subdir/baz
 
-RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null | FileCheck %s
-RUN: llvm-profdata merge -weighted-input=2,%t.dir2 -dump-input-file-list -o /dev/null %t.dir1 | FileCheck %s
+RUN: llvm-profdata merge -f %t.input --dump-input-file-list -o /dev/null | FileCheck %s
+RUN: llvm-profdata merge --weighted-input 2,%t.dir2 --dump-input-file-list -o /dev/null %t.dir1 | FileCheck %s
 
 CHECK-DAG: 1,{{.*}}.dir1{{[/\\]}}bar
 CHECK-DAG: 1,{{.*}}.dir1{{[/\\]}}foo
diff --git a/llvm/test/tools/llvm-profdata/input-filenames.test b/llvm/test/tools/llvm-profdata/input-filenames.test
index 4f29e7bea9b8f..048f940bd97f2 100644
--- a/llvm/test/tools/llvm-profdata/input-filenames.test
+++ b/llvm/test/tools/llvm-profdata/input-filenames.test
@@ -10,8 +10,8 @@ RUN: echo ' ' > %t.foo
 RUN: echo ' ' > %t.bar
 RUN: echo ' ' > %t.baz
 
-RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null %t.foo | FileCheck %s
-RUN: llvm-profdata merge -input-files %t.input -dump-input-file-list -o /dev/null %t.foo | FileCheck %s
+RUN: llvm-profdata merge -f %t.input --dump-input-file-list -o /dev/null %t.foo | FileCheck %s
+RUN: llvm-profdata merge --input-files %t.input --dump-input-file-list -o /dev/null %t.foo | FileCheck %s
 
 CHECK: 1,{{.*}}.foo
 CHECK-NEXT: 1,{{.*}}.bar
diff --git a/llvm/test/tools/llvm-profdata/input-wildcard.test b/llvm/test/tools/llvm-profdata/input-wildcard.test
index f2c46c962a817..115aa209012d2 100644
--- a/llvm/test/tools/llvm-profdata/input-wildcard.test
+++ b/llvm/test/tools/llvm-profdata/input-wildcard.test
@@ -8,7 +8,7 @@ RUN: echo '# empty profile 1' >  %t.prof1.proftxt
 RUN: echo '# empty profile 2' >> %t.prof2.proftxt
 
 # Prevent LIT itself from globbing by quoting the wildcard argument.
-RUN: llvm-profdata merge "%t.*.proftxt" -dump-input-file-list -o /dev/null | FileCheck %s
+RUN: llvm-profdata merge "%t.*.proftxt" --dump-input-file-list -o /dev/null | FileCheck %s
 
 # Verify that llvm-profdata expanded the wildcard argument.
 CHECK: 1,{{.*}}.prof1.proftxt
diff --git a/llvm/test/tools/llvm-profdata/instr-remap.test b/llvm/test/tools/llvm-profdata/instr-remap.test
index 27fddf6095812..82189b110dba4 100644
--- a/llvm/test/tools/llvm-profdata/instr-remap.test
+++ b/llvm/test/tools/llvm-profdata/instr-remap.test
@@ -1,2 +1,2 @@
-; RUN: llvm-profdata merge -text %S/Inputs/instr-remap.proftext -r %S/Inputs/instr-remap.remap -o %t.output
+; RUN: llvm-profdata merge --text %S/Inputs/instr-remap.proftext -r %S/Inputs/instr-remap.remap -o %t.output
 ; RUN: diff -b %S/Inputs/instr-remap.expected %t.output
diff --git a/llvm/test/tools/llvm-profdata/invalid-profdata.test b/llvm/test/tools/llvm-profdata/invalid-profdata.test
index efa16392e42e7..29006248272b7 100644
--- a/llvm/test/tools/llvm-profdata/invalid-profdata.test
+++ b/llvm/test/tools/llvm-profdata/invalid-profdata.test
@@ -20,7 +20,7 @@ RUN: echo "f2:0"                                         >> %t.input
 RUN: echo "1"                                            >> %t.input
 RUN: echo ":10"                                          >> %t.input
 
-RUN: not llvm-profdata merge %t.input -text -output=/dev/null 2>&1  | FileCheck %s --check-prefix=BROKEN
+RUN: not llvm-profdata merge %t.input --text -o /dev/null 2>&1  | FileCheck %s --check-prefix=BROKEN
 BROKEN: warning: {{.*}}invalid-profdata.test.tmp.input: malformed instrumentation profile data
 BROKEN-NEXT: error: no profile can be merged
 
@@ -46,6 +46,6 @@ RUN: echo "f2:0"                                         >> %t.input
 RUN: echo "1"                                            >> %t.input
 RUN: echo "** External Symbol **:10"             >> %t.input
 
-# RUN: llvm-profdata merge %t.input -text -output=%t.out && cat %t.out | FileCheck %s
+# RUN: llvm-profdata merge %t.input --text -o %t.out && cat %t.out | FileCheck %s
 
 CHECK: ** External Symbol **:10
diff --git a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test
index 157c13b926a7e..bd7159f0bea18 100644
--- a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test
+++ b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test
@@ -80,13 +80,13 @@ RUN: printf '\3\0foo\0\0\0' >> %t-good.profraw
 RUN: not llvm-profdata merge %t-bad.profraw %t-good.profraw -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ANY
 ANY: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937
 
-// -failure-mode=all only fails if there is a warning for every input file.
-RUN: not llvm-profdata merge %t-bad.profraw -failure-mode=all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-ERR
+// --failure-mode all only fails if there is a warning for every input file.
+RUN: not llvm-profdata merge %t-bad.profraw --failure-mode all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-ERR
 ALL-ERR: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937
 
-RUN: llvm-profdata merge %t-bad.profraw %t-good.profraw -failure-mode=all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-WARN
+RUN: llvm-profdata merge %t-bad.profraw %t-good.profraw --failure-mode all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-WARN
 ALL-WARN: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937
 
-// -failure-mode=warn does not fail at all. It only prints warnings.
-RUN: llvm-profdata merge %t-bad.profraw -failure-mode=warn -o %t.profdata 2>&1 | FileCheck %s --check-prefix=WARN
+// --failure-mode warn does not fail at all. It only prints warnings.
+RUN: llvm-profdata merge %t-bad.profraw --failure-mode warn -o %t.profdata 2>&1 | FileCheck %s --check-prefix=WARN
 WARN: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937
diff --git a/llvm/test/tools/llvm-profdata/mcdc-bitmap.test b/llvm/test/tools/llvm-profdata/mcdc-bitmap.test
index a7b1b5df8c306..9df65002df52d 100644
--- a/llvm/test/tools/llvm-profdata/mcdc-bitmap.test
+++ b/llvm/test/tools/llvm-profdata/mcdc-bitmap.test
@@ -3,10 +3,10 @@
 # Merge as profdata.
 RUN: split-file %s %t
 RUN: llvm-profdata merge %t/mcdc-1.proftext %t/mcdc-2.proftext -o %t.profdata
-RUN: llvm-profdata show %t.profdata --text -all-functions | FileCheck %s --check-prefix=MCDC
+RUN: llvm-profdata show %t.profdata --text --all-functions | FileCheck %s --check-prefix=MCDC
 # Merge as proftext.
 RUN: llvm-profdata merge %t/mcdc-1.proftext %t/mcdc-2.proftext -o %t.proftext
-RUN: llvm-profdata show %t.proftext --text -all-functions | FileCheck %s --check-prefix=MCDC
+RUN: llvm-profdata show %t.proftext --text --all-functions | FileCheck %s --check-prefix=MCDC
 
 MCDC: # Num Bitmap Bytes:
 MCDC-NEXT: $1
@@ -20,10 +20,10 @@ MCDC-NEXT: 0x0
 
 # Merge as profdata.
 RUN: llvm-profdata merge %t/mcdc-3.proftext %t/mcdc-4.proftext -o %t.profdata
-RUN: llvm-profdata show %t.profdata --text -all-functions | FileCheck %s --check-prefix=MCDC2
+RUN: llvm-profdata show %t.profdata --text --all-functions | FileCheck %s --check-prefix=MCDC2
 # Merge as proftext.
 RUN: llvm-profdata merge %t/mcdc-3.proftext %t/mcdc-4.proftext -o %t.proftext
-RUN: llvm-profdata show %t.proftext --text -all-functions | FileCheck %s --check-prefix=MCDC2
+RUN: llvm-profdata show %t.proftext --text --all-functions | FileCheck %s --check-prefix=MCDC2
 
 MCDC2: # Num Bitmap Bytes:
 MCDC2-NEXT: $8
diff --git a/llvm/test/tools/llvm-profdata/memop-size-prof.proftext b/llvm/test/tools/llvm-profdata/memop-size-prof.proftext
index 79dc0f8a16324..fa8eb623bb337 100644
--- a/llvm/test/tools/llvm-profdata/memop-size-prof.proftext
+++ b/llvm/test/tools/llvm-profdata/memop-size-prof.proftext
@@ -1,9 +1,9 @@
-# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %s | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
-# RUN: llvm-profdata show -memop-sizes -ic-targets -counts -text -function=foo %s | FileCheck %s --check-prefixes=TEXT,MEMOP_TEXT,ICALL_TEXT
+# RUN: llvm-profdata show --memop-sizes --ic-targets --function foo %s | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
+# RUN: llvm-profdata show --memop-sizes --ic-targets --counts --text --function foo %s | FileCheck %s --check-prefixes=TEXT,MEMOP_TEXT,ICALL_TEXT
 # RUN: llvm-profdata merge -o %t.profdata  %s
-# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %t.profdata | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
-# RUN: llvm-profdata merge -o %t.proftext -text %s
-# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %t.proftext| FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
+# RUN: llvm-profdata show --memop-sizes --ic-targets --function foo %t.profdata | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
+# RUN: llvm-profdata merge -o %t.proftext --text %s
+# RUN: llvm-profdata show --memop-sizes --ic-targets --function foo %t.proftext| FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM
 
 # IR level Instrumentation Flag
 :ir
diff --git a/llvm/test/tools/llvm-profdata/memprof-buildid.test b/llvm/test/tools/llvm-profdata/memprof-buildid.test
index 75c3da2506796..fb4a23eff6dc6 100644
--- a/llvm/test/tools/llvm-profdata/memprof-buildid.test
+++ b/llvm/test/tools/llvm-profdata/memprof-buildid.test
@@ -16,7 +16,7 @@ COM: Then match it with the profdata output.
 CHECK-COUNT-1: BuildId: {{.*}}[[ID]]
 
 Test error message when profile build id does not match build id in a different binary.
-RUN: not llvm-profdata show --memory %p/Inputs/buildid.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o - 2>&1 | FileCheck %s -check-prefix=BUILDID-NOT-MATCH
-RUN: not llvm-profdata merge %p/Inputs/buildid.memprofraw %p/Inputs/basic.memprofraw  --profiled-binary %p/Inputs/basic.memprofexe -o %t4.prof 2>&1 | FileCheck %s -check-prefix=BUILDID-NOT-MATCH
+RUN: not llvm-profdata show --memory %p/Inputs/buildid.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o - 2>&1 | FileCheck %s --check-prefix=BUILDID-NOT-MATCH
+RUN: not llvm-profdata merge %p/Inputs/buildid.memprofraw %p/Inputs/basic.memprofraw  --profiled-binary %p/Inputs/basic.memprofexe -o %t4.prof 2>&1 | FileCheck %s --check-prefix=BUILDID-NOT-MATCH
 
 BUILDID-NOT-MATCH: No matching executable segments found in binary
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
index 0a65872016259..91db00b44cb9b 100644
--- a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
+++ b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
@@ -7,16 +7,16 @@ RUN: echo "1" >> %t.proftext
 RUN: echo "1" >> %t.proftext
 
 To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=2 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 2 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2
 RUN: llvm-profdata show %t.prof.v2 | FileCheck %s
 
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=2 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 2 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2
 RUN: llvm-profdata show %t.prof.v2 | FileCheck %s
 
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=3 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 3 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3
 RUN: llvm-profdata show %t.prof.v3 | FileCheck %s
 
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=3 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 3 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3
 RUN: llvm-profdata show %t.prof.v3 | FileCheck %s
 
 Check to see if llvm-profdata produces V3 by default.
diff --git a/llvm/test/tools/llvm-profdata/memprof-yaml.test b/llvm/test/tools/llvm-profdata/memprof-yaml.test
index 69b3131a87f3d..3b24a5c5402c0 100644
--- a/llvm/test/tools/llvm-profdata/memprof-yaml.test
+++ b/llvm/test/tools/llvm-profdata/memprof-yaml.test
@@ -3,35 +3,35 @@
 
 ; Verify that the YAML output is identical to the YAML input.
 ; memprof-in.yaml has both heap profile records and data access profiles.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in.yaml -o %t/memprof-out.indexed
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in.yaml -o %t/memprof-out.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out.indexed > %t/memprof-out.yaml
 ; RUN: diff -b %t/memprof-in.yaml %t/memprof-out.yaml
 
 ; Merge text profile as v3 binary profile. Test that the merged v3 profile
 ; are identical to memprof-in-v3.yaml, and doesn't have callee guids or dap.
-; RUN: llvm-profdata merge --memprof-version=3 %t/memprof-in.yaml -o %t/memprof-out-v3.indexed
+; RUN: llvm-profdata merge --memprof-version 3 %t/memprof-in.yaml -o %t/memprof-out-v3.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out-v3.indexed > %t/memprof-out-v3.yaml
 ; RUN: diff -b %t/memprof-out-v3.yaml %t/memprof-in-v3.yaml
 
 ; Make sure we can ingest a YAML profile containing AllocSites only.
 ; That is, CallSites are missing.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-alloc-sites-only.yaml -o %t/memprof-out-alloc-sites-only.indexed
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-alloc-sites-only.yaml -o %t/memprof-out-alloc-sites-only.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out-alloc-sites-only.indexed > %t/memprof-out-alloc-sites-only.yaml
 ; RUN: diff -b %t/memprof-out-alloc-sites-only.yaml %t/memprof-in-alloc-sites-only.yaml
 
 ; Make sure we can ingest a YAML profile containing CallSites only.
 ; That is, AllocSites are missing.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-call-sites-only.yaml -o %t/memprof-out-call-sites-only.indexed
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-call-sites-only.yaml -o %t/memprof-out-call-sites-only.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out-call-sites-only.indexed > %t/memprof-out-call-sites-only.yaml
 ; RUN: diff -b %t/memprof-out-call-sites-only.yaml %t/memprof-in-call-sites-only.yaml
 
 ; memprof-in-no-dap.yaml has empty data access profiles.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-no-dap.yaml -o %t/memprof-out.indexed
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-no-dap.yaml -o %t/memprof-out.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out.indexed > %t/memprof-out-no-dap.yaml
 ; RUN: diff -b %t/memprof-in-no-dap.yaml %t/memprof-out-no-dap.yaml
 
 ; memprof-in-no-heap.yaml has empty heap access profiles.
-; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-no-heap.yaml -o %t/memprof-out-no-heap.indexed
+; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-no-heap.yaml -o %t/memprof-out-no-heap.indexed
 ; RUN: llvm-profdata show --memory %t/memprof-out-no-heap.indexed > %t/memprof-out-no-heap.yaml
 ; RUN: diff -b %t/memprof-in-no-heap.yaml %t/memprof-out-no-heap.yaml
 
diff --git a/llvm/test/tools/llvm-profdata/merge-filter.test b/llvm/test/tools/llvm-profdata/merge-filter.test
index 5c47c6a75a7c4..fecd127d73f9d 100644
--- a/llvm/test/tools/llvm-profdata/merge-filter.test
+++ b/llvm/test/tools/llvm-profdata/merge-filter.test
@@ -1,28 +1,28 @@
 Test llvm-profdata merge with function filters.
 
-RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function="_Z3.*" | FileCheck %s --check-prefix=CHECK-FILTER1
-RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --no-function="main" | FileCheck %s --check-prefix=CHECK-FILTER1
+RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function "_Z3.*" | FileCheck %s --check-prefix=CHECK-FILTER1
+RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --no-function "main" | FileCheck %s --check-prefix=CHECK-FILTER1
 CHECK-FILTER1: _Z3bari:20301:1437
 CHECK-NEXT:  1: 1437
 CHECK-NEXT: _Z3fooi:7711:610
 CHECK-NEXT:  1: 610
 CHECK-NOT: main
 
-RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function="_Z3.*" --no-function="fooi$" | FileCheck %s --check-prefix=CHECK-FILTER2
+RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function "_Z3.*" --no-function "fooi$" | FileCheck %s --check-prefix=CHECK-FILTER2
 CHECK-FILTER2: _Z3bari:20301:1437
 CHECK-NEXT:  1: 1437
 CHECK-NOT: main
 CHECK-NOT: _Z3fooi
 
-RUN: llvm-profdata merge --sample --extbinary --use-md5 -output=%t.0.profdata %p/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample %t.0.profdata --text --function="_Z3fooi" | FileCheck %s --check-prefix=CHECK-FILTER-MD5
+RUN: llvm-profdata merge --sample --extbinary --use-md5 -o %t.0.profdata %p/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample %t.0.profdata --text --function "_Z3fooi" | FileCheck %s --check-prefix=CHECK-FILTER-MD5
 CHECK-FILTER-MD5: 1228452328526475178:7711:610
 CHECK-NEXT:  1: 610
 CHECK-NOT: 15822663052811949562
 CHECK-NOT: 3727899762981752933
 
-RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function="foo" | FileCheck %s --check-prefix=CHECK-FILTER3
-RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --no-function="main" | FileCheck %s --check-prefix=CHECK-FILTER3
+RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function "foo" | FileCheck %s --check-prefix=CHECK-FILTER3
+RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --no-function "main" | FileCheck %s --check-prefix=CHECK-FILTER3
 CHECK-FILTER3: foo
 CHECK-NEXT: # Func Hash:
 CHECK-NEXT: 10
@@ -41,7 +41,7 @@ CHECK-NEXT: # Counter Values:
 CHECK-NEXT: 500500
 CHECK-NEXT: 180100
 
-RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function="foo" --no-function="^foo$" | FileCheck %s --check-prefix=CHECK-FILTER4
+RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function "foo" --no-function "^foo$" | FileCheck %s --check-prefix=CHECK-FILTER4
 CHECK-FILTER4: foo2
 CHECK-NEXT: # Func Hash:
 CHECK-NEXT: 10
@@ -51,7 +51,7 @@ CHECK-NEXT: # Counter Values:
 CHECK-NEXT: 500500
 CHECK-NEXT: 180100
 
-RUN: llvm-profdata merge --sample %p/Inputs/cs-sample.proftext --text --function="main.*@.*_Z5funcBi" | FileCheck %s --check-prefix=CHECK-FILTER5
+RUN: llvm-profdata merge --sample %p/Inputs/cs-sample.proftext --text --function "main.*@.*_Z5funcBi" | FileCheck %s --check-prefix=CHECK-FILTER5
 CHECK-FILTER5: [main:3.1 @ _Z5funcBi:1 @ _Z8funcLeafi]:500853:20
 CHECK-NEXT:  0: 15
 CHECK-NEXT:  1: 15
diff --git a/llvm/test/tools/llvm-profdata/merge-incompatible.test b/llvm/test/tools/llvm-profdata/merge-incompatible.test
index fca72a452069e..fab3b198c1b15 100644
--- a/llvm/test/tools/llvm-profdata/merge-incompatible.test
+++ b/llvm/test/tools/llvm-profdata/merge-incompatible.test
@@ -4,5 +4,5 @@ CHECK: ir-basic.proftext: Merge IR generated profile with Clang generated profil
 
 // We get a slightly different error message when using multiple threads because
 // we do not know which files have incompatible kinds.
-RUN: not llvm-profdata merge %p/Inputs/fe-basic.proftext %p/Inputs/ir-basic.proftext --num-threads=2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=THREADS
+RUN: not llvm-profdata merge %p/Inputs/fe-basic.proftext %p/Inputs/ir-basic.proftext --num-threads 2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=THREADS
 THREADS: unsupported instrumentation profile format version
diff --git a/llvm/test/tools/llvm-profdata/merge-probe-profile.test b/llvm/test/tools/llvm-profdata/merge-probe-profile.test
index d05c950728747..a64750429452a 100644
--- a/llvm/test/tools/llvm-profdata/merge-probe-profile.test
+++ b/llvm/test/tools/llvm-profdata/merge-probe-profile.test
@@ -23,5 +23,5 @@ MERGE2:  5: 14 _Z3foov:10 _Z3barv:4
 MERGE2:  6: 12 _Z3barv:8 _Z3foov:4
 MERGE2:  !CFGChecksum: 563022570642068
 
-RUN: llvm-profdata show --sample -show-sec-info-only %t | FileCheck %s
+RUN: llvm-profdata show --sample --show-sec-info-only %t | FileCheck %s
 CHECK: FunctionMetadata {{.*}} Flags: {probe}
\ No newline at end of file
diff --git a/llvm/test/tools/llvm-profdata/merge-traces.proftext b/llvm/test/tools/llvm-profdata/merge-traces.proftext
index 3512f33cd06a9..fcb6034130af8 100644
--- a/llvm/test/tools/llvm-profdata/merge-traces.proftext
+++ b/llvm/test/tools/llvm-profdata/merge-traces.proftext
@@ -1,23 +1,23 @@
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s --text | FileCheck %s --check-prefixes=CHECK,SEEN1,SAMPLE1
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s --text | FileCheck %s --check-prefixes=CHECK,SEEN1,SAMPLE1
 
 # Merge %s twice so it has two traces
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN2,SAMPLE2
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s -o %t-2.profdata
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN2,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s -o %t-2.profdata
 
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2
 
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2
 
 # Test that we can increase the reservoir size, even if inputs are sampled
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t-4.profdata
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=4 %t-4.profdata %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN8,SAMPLE4
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s -o %t-4.profdata
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 4 %t-4.profdata %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN8,SAMPLE4
 
 # Test that decreasing the reservoir size truncates traces
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=1 %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE1
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 1 %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE1
 
 # CHECK: :temporal_prof_traces
 # CHECK: # Num Temporal Profile Traces:
diff --git a/llvm/test/tools/llvm-profdata/merge_empty_profile.test b/llvm/test/tools/llvm-profdata/merge_empty_profile.test
index 013a4dcda6554..c3a3faef48476 100644
--- a/llvm/test/tools/llvm-profdata/merge_empty_profile.test
+++ b/llvm/test/tools/llvm-profdata/merge_empty_profile.test
@@ -1,15 +1,15 @@
 # Tests for merge of empty profile files.
 
 RUN: touch %t_empty.proftext
-RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext | FileCheck %s -check-prefix=CLANG_PROF_TEXT
-RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext --num-threads=2 | FileCheck %s -check-prefix=CLANG_PROF_TEXT
+RUN: llvm-profdata merge --text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext | FileCheck %s --check-prefix=CLANG_PROF_TEXT
+RUN: llvm-profdata merge --text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext --num-threads 2 | FileCheck %s --check-prefix=CLANG_PROF_TEXT
 CLANG_PROF_TEXT: main
 CLANG_PROF_TEXT: 0
 CLANG_PROF_TEXT: 1
 CLANG_PROF_TEXT: 1
 
-RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext | FileCheck %s -check-prefix=IR_PROF_TEXT
-RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext --num-threads=2 | FileCheck %s -check-prefix=IR_PROF_TEXT
+RUN: llvm-profdata merge --text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext | FileCheck %s --check-prefix=IR_PROF_TEXT
+RUN: llvm-profdata merge --text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext --num-threads 2 | FileCheck %s --check-prefix=IR_PROF_TEXT
 IR_PROF_TEXT: :ir
 IR_PROF_TEXT: main
 IR_PROF_TEXT: 0
diff --git a/llvm/test/tools/llvm-profdata/multiple-inputs.test b/llvm/test/tools/llvm-profdata/multiple-inputs.test
index 3a3caeac0c2e3..d2d93a6459e7e 100644
--- a/llvm/test/tools/llvm-profdata/multiple-inputs.test
+++ b/llvm/test/tools/llvm-profdata/multiple-inputs.test
@@ -1,9 +1,9 @@
 Some very basic tests for the multiple input cases.
 
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-2.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO3
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO3
 RUN: llvm-profdata merge %p/Inputs/foo3-2.proftext %p/Inputs/foo3-1.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO3
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO3
 FOO3: foo:
 FOO3: Counters: 3
 FOO3: Function count: 8
@@ -13,7 +13,7 @@ FOO3: Maximum function count: 8
 FOO3: Maximum internal block count: 7
 
 RUN: llvm-profdata merge %p/Inputs/empty.proftext %p/Inputs/foo3-1.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO3EMPTY
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO3EMPTY
 FOO3EMPTY: foo:
 FOO3EMPTY: Counters: 3
 FOO3EMPTY: Function count: 1
@@ -23,8 +23,8 @@ FOO3EMPTY: Maximum function count: 1
 FOO3EMPTY: Maximum internal block count: 3
 
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3bar3-1.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefixes=FOO3FOO3BAR3,FOO3FOO3BAR3-1
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefixes=FOO3FOO3BAR3,FOO3FOO3BAR3-2
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefixes=FOO3FOO3BAR3,FOO3FOO3BAR3-1
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefixes=FOO3FOO3BAR3,FOO3FOO3BAR3-2
 FOO3FOO3BAR3-1: foo:
 FOO3FOO3BAR3-1: Counters: 3
 FOO3FOO3BAR3-1: Function count: 3
@@ -38,8 +38,8 @@ FOO3FOO3BAR3: Maximum function count: 7
 FOO3FOO3BAR3: Maximum internal block count: 13
 
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/bar3-1.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefixes=DISJOINT,DISJOINT-1
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefixes=DISJOINT,DISJOINT-2
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefixes=DISJOINT,DISJOINT-1
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefixes=DISJOINT,DISJOINT-2
 DISJOINT-1: foo:
 DISJOINT-1: Counters: 3
 DISJOINT-1: Function count: 1
@@ -54,12 +54,12 @@ DISJOINT: Maximum internal block count: 3
 
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
-RUN:                     -num-threads 2 -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO4
+RUN:                     --num-threads 2 -o %t
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO4
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     -j 3 -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO4
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO4
 FOO4: foo:
 FOO4: Counters: 3
 FOO4: Function count: 4
@@ -71,19 +71,19 @@ FOO4: Maximum internal block count: 12
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext -j 2 -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO5
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO5
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext -j 3 -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO5
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO5
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO5
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO5
 RUN: llvm-profdata merge %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext %p/Inputs/foo3-1.proftext \
 RUN:                     %p/Inputs/foo3-1.proftext -j 1 -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO5
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FOO5
 FOO5: foo:
 FOO5: Counters: 3
 FOO5: Function count: 5
diff --git a/llvm/test/tools/llvm-profdata/overflow-instr.test b/llvm/test/tools/llvm-profdata/overflow-instr.test
index 5541a67dc5f3e..6ed91a9c4bd0e 100644
--- a/llvm/test/tools/llvm-profdata/overflow-instr.test
+++ b/llvm/test/tools/llvm-profdata/overflow-instr.test
@@ -1,15 +1,15 @@
 Tests for overflow when merging instrumented profiles.
 
 1- Merge profile having maximum counts with itself and verify overflow detected and saturation occurred
-RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW
-RUN: llvm-profdata show -instr -all-functions -counts %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
+RUN: llvm-profdata merge --instr %p/Inputs/overflow-instr.proftext %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW
+RUN: llvm-profdata show --instr --all-functions --counts %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
 MERGE_OVERFLOW: {{.*}}.proftext: overflow: counter overflow
 SHOW_OVERFLOW: Function count: 18446744073709551613
 SHOW_OVERFLOW-NEXT: Block counts: [18446744073709551613, 18446744073709551613]
 
 2- Merge profile having maximum counts by itself and verify no overflow
-RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_NO_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
+RUN: llvm-profdata merge --instr %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=MERGE_NO_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
 MERGE_NO_OVERFLOW-NOT: {{.*}}.proftext: overflow: counter overflow
 SHOW_NO_OVERFLOW: Function count: 18446744073709551613
 SHOW_NO_OVERFLOW-NEXT: Block counts: [9223372036854775808, 18446744073709551613]
diff --git a/llvm/test/tools/llvm-profdata/overflow-sample.test b/llvm/test/tools/llvm-profdata/overflow-sample.test
index 83adf6d63b549..1a8b2da01c11d 100644
--- a/llvm/test/tools/llvm-profdata/overflow-sample.test
+++ b/llvm/test/tools/llvm-profdata/overflow-sample.test
@@ -1,8 +1,8 @@
 Tests for overflow when merging sampled profiles.
 
 1- Merge profile having maximum counts with itself and verify overflow detected
-RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW
-RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
+RUN: llvm-profdata merge --sample %p/Inputs/overflow-sample.proftext %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW
+RUN: llvm-profdata show --sample %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
 MERGE_OVERFLOW: {{.*}}: main: Counter overflow
 SHOW_OVERFLOW-DAG: Function: main: 2000, 0, 2 sampled lines
 SHOW_OVERFLOW-DAG: Samples collected in the function's body {
@@ -22,8 +22,8 @@ SHOW_OVERFLOW-DAG: }
 SHOW_OVERFLOW-DAG: No inlined callsites in this function
 
 2- Merge profile having maximum counts by itself and verify no overflow
-RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -allow-empty -check-prefix=MERGE_NO_OVERFLOW
-RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
+RUN: llvm-profdata merge --sample %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s --allow-empty --check-prefix=MERGE_NO_OVERFLOW
+RUN: llvm-profdata show --sample %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
 MERGE_NO_OVERFLOW-NOT: {{.*}}: main: Counter overflow
 SHOW_NO_OVERFLOW-DAG: Function: main: 1000, 0, 2 sampled lines
 SHOW_NO_OVERFLOW-DAG: Samples collected in the function's body {
diff --git a/llvm/test/tools/llvm-profdata/overlap.test b/llvm/test/tools/llvm-profdata/overlap.test
index 6470e3f19712b..6cd1d7a4ec9b5 100644
--- a/llvm/test/tools/llvm-profdata/overlap.test
+++ b/llvm/test/tools/llvm-profdata/overlap.test
@@ -1,9 +1,9 @@
-RUN: llvm-profdata overlap %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s -check-prefix=OVERLAP
-RUN: llvm-profdata overlap -function=main %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP
-RUN: llvm-profdata overlap -value-cutoff=15000 %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP
+RUN: llvm-profdata overlap %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefix=OVERLAP
+RUN: llvm-profdata overlap --function main %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP
+RUN: llvm-profdata overlap --value-cutoff 15000 %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP
 RUN: llvm-profdata merge %p/Inputs/overlap_1.proftext -o %t_1.profdata
 RUN: llvm-profdata merge %p/Inputs/overlap_2.proftext -o %t_2.profdata
-RUN: llvm-profdata overlap %t_1.profdata %t_2.profdata | FileCheck %s -check-prefix=OVERLAP
+RUN: llvm-profdata overlap %t_1.profdata %t_2.profdata | FileCheck %s --check-prefix=OVERLAP
 MAINFUNC: Function: main (Hash=29212902728)
 MAINFUNC:   # of edge counters overlap: 2
 MAINFUNC:   Edge profile overlap: 100.000%
diff --git a/llvm/test/tools/llvm-profdata/overlap_cs.test b/llvm/test/tools/llvm-profdata/overlap_cs.test
index ba15418f87da8..bee9a87fb49f2 100644
--- a/llvm/test/tools/llvm-profdata/overlap_cs.test
+++ b/llvm/test/tools/llvm-profdata/overlap_cs.test
@@ -1,7 +1,7 @@
-RUN: llvm-profdata overlap -cs %p/Inputs/overlap_1_cs.proftext %p/Inputs/overlap_2_cs.proftext | FileCheck %s -check-prefix=OVERLAP
+RUN: llvm-profdata overlap --cs %p/Inputs/overlap_1_cs.proftext %p/Inputs/overlap_2_cs.proftext | FileCheck %s --check-prefix=OVERLAP
 RUN: llvm-profdata merge %p/Inputs/overlap_1_cs.proftext -o %t_1_cs.profdata
 RUN: llvm-profdata merge %p/Inputs/overlap_2_cs.proftext -o %t_2_cs.profdata
-RUN: llvm-profdata overlap -cs %t_1_cs.profdata %t_2_cs.profdata | FileCheck %s -check-prefix=OVERLAP
+RUN: llvm-profdata overlap --cs %t_1_cs.profdata %t_2_cs.profdata | FileCheck %s --check-prefix=OVERLAP
 OVERLAP: Profile overlap information for base_profile: {{.*}} and test_profile:
 OVERLAP: Program level:
 OVERLAP:  # of functions overlap: 1
diff --git a/llvm/test/tools/llvm-profdata/overlap_vp.test b/llvm/test/tools/llvm-profdata/overlap_vp.test
index 4425696ab419c..b304acff16d5e 100644
--- a/llvm/test/tools/llvm-profdata/overlap_vp.test
+++ b/llvm/test/tools/llvm-profdata/overlap_vp.test
@@ -1,7 +1,7 @@
-RUN: llvm-profdata overlap %p/Inputs/overlap_1_vp.proftext %p/Inputs/overlap_2_vp.proftext | FileCheck %s -check-prefix=OVERLAP
+RUN: llvm-profdata overlap %p/Inputs/overlap_1_vp.proftext %p/Inputs/overlap_2_vp.proftext | FileCheck %s --check-prefix=OVERLAP
 RUN: llvm-profdata merge %p/Inputs/overlap_1_vp.proftext -o %t_1_vp.profdata
 RUN: llvm-profdata merge %p/Inputs/overlap_2_vp.proftext -o %t_2_vp.profdata
-RUN: llvm-profdata overlap %t_1_vp.profdata %t_2_vp.profdata | FileCheck %s -check-prefix=OVERLAP
+RUN: llvm-profdata overlap %t_1_vp.profdata %t_2_vp.profdata | FileCheck %s --check-prefix=OVERLAP
 OVERLAP: Profile overlap information for base_profile: {{.*}} and test_profile:
 OVERLAP: Program level:
 OVERLAP:   # of functions overlap: 1
diff --git a/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test b/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test
index 8383bcc1a2fbe..d6dac11a15f10 100644
--- a/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test
+++ b/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test
@@ -1,15 +1,15 @@
 REQUIRES: zlib
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -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 -compress-all-sections -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections %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: llvm-profdata merge --sample --extbinary --compress-all-sections --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 --compress-all-sections --prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
+; RUN: llvm-profdata merge --sample --extbinary --compress-all-sections %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
 
 ;; Generate two SampleFDO binary profiles and merge them.
 ;; Tests that the vtable counters in the merged profile are the aggregated
 ;; result from both sources.
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output
-; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof %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: llvm-profdata merge --sample --extbinary --compress-all-sections --extbinary-write-vtable-type-prof --prof-sym-list %S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output
+; RUN: llvm-profdata merge --sample --extbinary --compress-all-sections --extbinary-write-vtable-type-prof --prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output
+; RUN: llvm-profdata merge --sample --extbinary --compress-all-sections --extbinary-write-vtable-type-prof %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-ext.expected %t.4.output
diff --git a/llvm/test/tools/llvm-profdata/profile-symbol-list.test b/llvm/test/tools/llvm-profdata/profile-symbol-list.test
index 6845531066c76..8e2a964f25ae1 100644
--- a/llvm/test/tools/llvm-profdata/profile-symbol-list.test
+++ b/llvm/test/tools/llvm-profdata/profile-symbol-list.test
@@ -1,18 +1,18 @@
-; RUN: llvm-profdata merge -sample -extbinary -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 -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
-; 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: llvm-profdata merge --sample --extbinary --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 --prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
+; 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
+; 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
 
 ;; Generate two SampleFDO binary profiles and merge them.
 ;; Tests that the vtable counters in the merged profile are the aggregated
 ;; result from both sources.
-; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output
-; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output
-; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof %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: llvm-profdata merge --sample --extbinary --extbinary-write-vtable-type-prof --prof-sym-list %S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output
+; RUN: llvm-profdata merge --sample --extbinary --extbinary-write-vtable-type-prof --prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output
+; RUN: llvm-profdata merge --sample --extbinary --extbinary-write-vtable-type-prof %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-ext.expected %t.4.output
diff --git a/llvm/test/tools/llvm-profdata/pseudo_count.test b/llvm/test/tools/llvm-profdata/pseudo_count.test
index 7915866d3270f..60d743d9a5eb8 100644
--- a/llvm/test/tools/llvm-profdata/pseudo_count.test
+++ b/llvm/test/tools/llvm-profdata/pseudo_count.test
@@ -1,17 +1,17 @@
 Tests for merging instrumented profiles with pseudo counts.
 
-RUN: llvm-profdata merge -instr %p/Inputs/pseudo-count-warm.proftext -o %t1.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t1.out | FileCheck %s --check-prefix=MERGE_WARM
-RUN: llvm-profdata merge -instr %p/Inputs/pseudo-count-warm.proftext %p/Inputs/pseudo-count-warm.proftext -o %t2.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t2.out | FileCheck %s --check-prefix=MERGE_WARM
-RUN: llvm-profdata merge -instr %p/Inputs/pseudo-count-hot.proftext -o %t3.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t3.out | FileCheck %s --check-prefix=MERGE_HOT
-RUN: llvm-profdata merge -instr %p/Inputs/pseudo-count-hot.proftext %p/Inputs/pseudo-count-hot.proftext -o %t4.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t4.out | FileCheck %s --check-prefix=MERGE_HOT
-RUN: llvm-profdata merge -instr %p/Inputs/pseudo-count-hot.proftext %p/Inputs/pseudo-count-warm.proftext -o %t5.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW -allow-empty
-RUN: llvm-profdata show -instr -all-functions -counts %t5.out | FileCheck %s --check-prefix=MERGE_HOT
-RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext %p/Inputs/pseudo-count-warm.proftext -o %t6.out 2>&1 | FileCheck %s -check-prefix=MERGE_WARNING
-RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext %p/Inputs/pseudo-count-hot.proftext -o %t7.out 2>&1 | FileCheck %s -check-prefix=MERGE_WARNING
+RUN: llvm-profdata merge --instr %p/Inputs/pseudo-count-warm.proftext -o %t1.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t1.out | FileCheck %s --check-prefix=MERGE_WARM
+RUN: llvm-profdata merge --instr %p/Inputs/pseudo-count-warm.proftext %p/Inputs/pseudo-count-warm.proftext -o %t2.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t2.out | FileCheck %s --check-prefix=MERGE_WARM
+RUN: llvm-profdata merge --instr %p/Inputs/pseudo-count-hot.proftext -o %t3.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t3.out | FileCheck %s --check-prefix=MERGE_HOT
+RUN: llvm-profdata merge --instr %p/Inputs/pseudo-count-hot.proftext %p/Inputs/pseudo-count-hot.proftext -o %t4.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t4.out | FileCheck %s --check-prefix=MERGE_HOT
+RUN: llvm-profdata merge --instr %p/Inputs/pseudo-count-hot.proftext %p/Inputs/pseudo-count-warm.proftext -o %t5.out 2>&1 | FileCheck %s --check-prefix=MERGE_OVERFLOW --allow-empty
+RUN: llvm-profdata show --instr --all-functions --counts %t5.out | FileCheck %s --check-prefix=MERGE_HOT
+RUN: llvm-profdata merge --instr %p/Inputs/overflow-instr.proftext %p/Inputs/pseudo-count-warm.proftext -o %t6.out 2>&1 | FileCheck %s --check-prefix=MERGE_WARNING
+RUN: llvm-profdata merge --instr %p/Inputs/overflow-instr.proftext %p/Inputs/pseudo-count-hot.proftext -o %t7.out 2>&1 | FileCheck %s --check-prefix=MERGE_WARNING
 
 MERGE_OVERFLOW-NOT: {{.*}}.proftext: overflow: counter overflow
 MERGE_WARM: Counters: 3    <PseudoWarm>
diff --git a/llvm/test/tools/llvm-profdata/raw-32-bits-be.test b/llvm/test/tools/llvm-profdata/raw-32-bits-be.test
index 6b3dc96b36270..328f561057cda 100644
--- a/llvm/test/tools/llvm-profdata/raw-32-bits-be.test
+++ b/llvm/test/tools/llvm-profdata/raw-32-bits-be.test
@@ -45,8 +45,8 @@ RUN: printf '\0\0\0\0\0\0\0\101' >> %t
 RUN: printf '\125\125\125\052' >> %t
 RUN: printf '\7\0foo\1bar\0\0\0\0\0\0\0' >> %t
 
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
-RUN: llvm-profdata show %t -all-functions -text | FileCheck %s -check-prefix=MCDC
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s
+RUN: llvm-profdata show %t --all-functions --text | FileCheck %s --check-prefix=MCDC
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/llvm/test/tools/llvm-profdata/raw-32-bits-le.test b/llvm/test/tools/llvm-profdata/raw-32-bits-le.test
index 95625565f5c0c..3b4100ee845ce 100644
--- a/llvm/test/tools/llvm-profdata/raw-32-bits-le.test
+++ b/llvm/test/tools/llvm-profdata/raw-32-bits-le.test
@@ -44,8 +44,8 @@ RUN: printf '\101\0\0\0\0\0\0\0' >> %t
 RUN: printf '\125\125\125\052' >> %t
 RUN: printf '\7\0foo\1bar\0\0\0\0\0\0\0' >> %t
 
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
-RUN: llvm-profdata show %t -all-functions -text | FileCheck %s -check-prefix=MCDC
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s
+RUN: llvm-profdata show %t --all-functions --text | FileCheck %s --check-prefix=MCDC
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/llvm/test/tools/llvm-profdata/raw-64-bits-be.test b/llvm/test/tools/llvm-profdata/raw-64-bits-be.test
index 5316ef5a3e559..9e7bc1ad6b349 100644
--- a/llvm/test/tools/llvm-profdata/raw-64-bits-be.test
+++ b/llvm/test/tools/llvm-profdata/raw-64-bits-be.test
@@ -44,8 +44,8 @@ RUN: printf '\0\0\0\0\0\0\0\101' >> %t
 RUN: printf '\125\125\125\052' >> %t
 RUN: printf '\7\0foo\1bar\0\0\0\0\0\0\0' >> %t
 
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
-RUN: llvm-profdata show %t -all-functions -text | FileCheck %s -check-prefix=MCDC
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s
+RUN: llvm-profdata show %t --all-functions --text | FileCheck %s --check-prefix=MCDC
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/llvm/test/tools/llvm-profdata/raw-64-bits-le.test b/llvm/test/tools/llvm-profdata/raw-64-bits-le.test
index 58f4da8cf0386..8e3104b94b6bc 100644
--- a/llvm/test/tools/llvm-profdata/raw-64-bits-le.test
+++ b/llvm/test/tools/llvm-profdata/raw-64-bits-le.test
@@ -44,8 +44,8 @@ RUN: printf '\101\0\0\0\0\0\0\0' >> %t
 RUN: printf '\125\125\125\052' >> %t
 RUN: printf '\7\0foo\1bar\0\0\0\0\0\0\0' >> %t
 
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
-RUN: llvm-profdata show %t -all-functions -text | FileCheck %s -check-prefix=MCDC
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s
+RUN: llvm-profdata show %t --all-functions --text | FileCheck %s --check-prefix=MCDC
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/llvm/test/tools/llvm-profdata/raw-two-profiles.test b/llvm/test/tools/llvm-profdata/raw-two-profiles.test
index 47cc6fa4fd7fe..7706664713d94 100644
--- a/llvm/test/tools/llvm-profdata/raw-two-profiles.test
+++ b/llvm/test/tools/llvm-profdata/raw-two-profiles.test
@@ -61,7 +61,7 @@ RUN: printf '\101\0\0\0\0\0\0\0' >> %t-bar.profraw
 RUN: printf '\3\0bar\0\0\0' >> %t-bar.profraw
 
 RUN: cat %t-foo.profraw %t-bar.profraw > %t-pad.profraw
-RUN: llvm-profdata show %t-pad.profraw -all-functions -counts | FileCheck %s
+RUN: llvm-profdata show %t-pad.profraw --all-functions --counts | FileCheck %s
 
 CHECK: Counters:
 CHECK:   foo:
diff --git a/llvm/test/tools/llvm-profdata/read-traces.proftext b/llvm/test/tools/llvm-profdata/read-traces.proftext
index 5e822a9ea53ec..79e961cf03ce1 100644
--- a/llvm/test/tools/llvm-profdata/read-traces.proftext
+++ b/llvm/test/tools/llvm-profdata/read-traces.proftext
@@ -1,9 +1,9 @@
-# RUN: llvm-profdata merge -text %s -o %t.1.proftext
-# RUN: llvm-profdata merge -binary %t.1.proftext -o %t.2.profdata
-# RUN: llvm-profdata merge -text %t.2.profdata -o %t.3.proftext
+# RUN: llvm-profdata merge --text %s -o %t.1.proftext
+# RUN: llvm-profdata merge --binary %t.1.proftext -o %t.2.profdata
+# RUN: llvm-profdata merge --text %t.2.profdata -o %t.3.proftext
 # RUN: diff %t.1.proftext %t.3.proftext
 
-# RUN: llvm-profdata merge -text %s | FileCheck %s
+# RUN: llvm-profdata merge --text %s | FileCheck %s
 
 # CHECK:      :temporal_prof_traces
 # CHECK:      # Num Temporal Profile Traces:
diff --git a/llvm/test/tools/llvm-profdata/roundtrip-compress.test b/llvm/test/tools/llvm-profdata/roundtrip-compress.test
index cf0c344e7874b..56bafe752a610 100644
--- a/llvm/test/tools/llvm-profdata/roundtrip-compress.test
+++ b/llvm/test/tools/llvm-profdata/roundtrip-compress.test
@@ -1,10 +1,10 @@
 REQUIRES: zlib
 # Round trip from text --> compressed extbinary --> text
-RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -output=%t.1.profdata %S/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample --text -output=%t.1.proftext %t.1.profdata
+RUN: llvm-profdata merge --sample --extbinary --compress-all-sections -o %t.1.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --text -o %t.1.proftext %t.1.profdata
 RUN: diff -b %t.1.proftext %S/Inputs/sample-profile.proftext
 # Round trip from text --> binary --> compressed extbinary --> text
-RUN: llvm-profdata merge --sample --binary -output=%t.2.profdata %S/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -output=%t.3.profdata %t.2.profdata
-RUN: llvm-profdata merge --sample --text -output=%t.2.proftext %t.3.profdata
+RUN: llvm-profdata merge --sample --binary -o %t.2.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --extbinary --compress-all-sections -o %t.3.profdata %t.2.profdata
+RUN: llvm-profdata merge --sample --text -o %t.2.proftext %t.3.profdata
 RUN: diff -b %t.2.proftext %S/Inputs/sample-profile.proftext
diff --git a/llvm/test/tools/llvm-profdata/roundtrip.test b/llvm/test/tools/llvm-profdata/roundtrip.test
index eb55534763877..2351a0deff0db 100644
--- a/llvm/test/tools/llvm-profdata/roundtrip.test
+++ b/llvm/test/tools/llvm-profdata/roundtrip.test
@@ -1,24 +1,24 @@
 RUN: llvm-profdata merge -o %t.0.profdata %S/Inputs/IR_profile.proftext
-RUN: llvm-profdata show -o %t.0.proftext -all-functions -text %t.0.profdata 
+RUN: llvm-profdata show -o %t.0.proftext --all-functions --text %t.0.profdata 
 RUN: diff -b %t.0.proftext %S/Inputs/IR_profile.proftext
 RUN: llvm-profdata merge -o %t.1.profdata %t.0.proftext
-RUN: llvm-profdata show -o %t.1.proftext -all-functions -text %t.1.profdata 
+RUN: llvm-profdata show -o %t.1.proftext --all-functions --text %t.1.profdata 
 RUN: diff -b %t.1.proftext %S/Inputs/IR_profile.proftext
-RUN: llvm-profdata merge --sample --binary -output=%t.2.profdata %S/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample --text -output=%t.2.proftext %t.2.profdata
+RUN: llvm-profdata merge --sample --binary -o %t.2.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --text -o %t.2.proftext %t.2.profdata
 RUN: diff -b %t.2.proftext %S/Inputs/sample-profile.proftext
 # Round trip from text --> extbinary --> text
-RUN: llvm-profdata merge --sample --extbinary -output=%t.3.profdata %S/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample --text -output=%t.3.proftext %t.3.profdata
+RUN: llvm-profdata merge --sample --extbinary -o %t.3.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --text -o %t.3.proftext %t.3.profdata
 RUN: diff -b %t.3.proftext %S/Inputs/sample-profile.proftext
 # Round trip from text --> binary --> extbinary --> text
-RUN: llvm-profdata merge --sample --binary -output=%t.4.profdata %S/Inputs/sample-profile.proftext
-RUN: llvm-profdata merge --sample --extbinary -output=%t.5.profdata %t.4.profdata
-RUN: llvm-profdata merge --sample --text -output=%t.4.proftext %t.5.profdata
+RUN: llvm-profdata merge --sample --binary -o %t.4.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --extbinary -o %t.5.profdata %t.4.profdata
+RUN: llvm-profdata merge --sample --text -o %t.4.proftext %t.5.profdata
 RUN: diff -b %t.4.proftext %S/Inputs/sample-profile.proftext
 # Round trip from text --> extbinary --> text.
 # The vtable profile is supported by ext-binary profile but not raw binary profile format,
 # so we don't use raw binary profile format in this roundtrip.
-RUN: llvm-profdata merge --sample --extbinary -extbinary-write-vtable-type-prof --output=%t.5.profdata %S/Inputs/sample-profile-ext.proftext
-RUN: llvm-profdata merge --sample --text --output=%t.5.proftext %t.5.profdata
+RUN: llvm-profdata merge --sample --extbinary --extbinary-write-vtable-type-prof -o %t.5.profdata %S/Inputs/sample-profile-ext.proftext
+RUN: llvm-profdata merge --sample --text -o %t.5.proftext %t.5.profdata
 RUN: diff -b %t.5.proftext %S/Inputs/sample-profile-ext.proftext
diff --git a/llvm/test/tools/llvm-profdata/same-filename.test b/llvm/test/tools/llvm-profdata/same-filename.test
index 1bb437b844ec6..d2d95761e260f 100644
--- a/llvm/test/tools/llvm-profdata/same-filename.test
+++ b/llvm/test/tools/llvm-profdata/same-filename.test
@@ -2,13 +2,13 @@ Test the input file names overlap with the output file names.
 
 This is OK for merging instrument profiles.
 RUN: cp %S/Inputs/same-name-1.proftext %t.0.proftext
-RUN: llvm-profdata merge -o %t.0.profdata -text %t.0.proftext %t.0.proftext
-RUN: llvm-profdata show -counts -all-functions %t.0.profdata -o %t_show_0
-RUN: llvm-profdata show -counts -all-functions %S/Inputs/same-name-2.proftext -o %t_show_1
+RUN: llvm-profdata merge -o %t.0.profdata --text %t.0.proftext %t.0.proftext
+RUN: llvm-profdata show --counts --all-functions %t.0.profdata -o %t_show_0
+RUN: llvm-profdata show --counts --all-functions %S/Inputs/same-name-2.proftext -o %t_show_1
 RUN: diff %t_show_0 %t_show_1
 RUN: llvm-profdata merge -o %t.1.profdata %S/Inputs/same-name-1.proftext
 RUN: llvm-profdata merge -o %t.1.profdata %t.1.profdata %t.1.profdata
-RUN: llvm-profdata show -counts -all-functions %t.1.profdata -o %t_show_2
+RUN: llvm-profdata show --counts --all-functions %t.1.profdata -o %t_show_2
 RUN: diff %t_show_2 %t_show_1
 
 We report error for the show command.
@@ -17,11 +17,11 @@ CHECK: llvm-profdata{{.*}} show: Input file name cannot be the same as the outpu
 
 This is OK for merging sample fdo profiles.
 RUN: cp %S/Inputs/same-name-3.proftext %t.3.proftext
-RUN: llvm-profdata merge --sample -o %t.3.profdata -text %t.3.proftext %t.3.proftext
-RUN: llvm-profdata show --sample -counts -all-functions %t.3.profdata -o %t_show_3
-RUN: llvm-profdata show --sample -counts -all-functions %S/Inputs/same-name-4.proftext -o %t_show_4
+RUN: llvm-profdata merge --sample -o %t.3.profdata --text %t.3.proftext %t.3.proftext
+RUN: llvm-profdata show --sample --counts --all-functions %t.3.profdata -o %t_show_3
+RUN: llvm-profdata show --sample --counts --all-functions %S/Inputs/same-name-4.proftext -o %t_show_4
 RUN: diff %t_show_3 %t_show_4
 RUN: llvm-profdata merge --sample -o %t.5.profdata %S/Inputs/same-name-3.proftext
 RUN: llvm-profdata merge --sample -o %t.5.profdata %t.5.profdata %t.5.profdata
-RUN: llvm-profdata show --sample -counts -all-functions %t.5.profdata -o %t_show_6
+RUN: llvm-profdata show --sample --counts --all-functions %t.5.profdata -o %t_show_6
 RUN: diff %t_show_6 %t_show_4
diff --git a/llvm/test/tools/llvm-profdata/sample-flatten-profile.test b/llvm/test/tools/llvm-profdata/sample-flatten-profile.test
index f99021bc6b723..d55e3c47c99c3 100644
--- a/llvm/test/tools/llvm-profdata/sample-flatten-profile.test
+++ b/llvm/test/tools/llvm-profdata/sample-flatten-profile.test
@@ -1,8 +1,8 @@
-; RUN: llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %S/Inputs/sample-flatten-profile.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace
-; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace
+; RUN: llvm-profdata merge --sample --convert-sample-profile-layout flat --text %S/Inputs/sample-flatten-profile.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace
+; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace
 
-; RUN: llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %S/Inputs/sample-flatten-profile-cs.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS
-; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile-cs.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS
+; RUN: llvm-profdata merge --sample --convert-sample-profile-layout flat --text %S/Inputs/sample-flatten-profile-cs.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS
+; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile-cs.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS
 
 ; CHECK:baz:169:10
 ; CHECK-NEXT: 1: 10
diff --git a/llvm/test/tools/llvm-profdata/sample-fs.test b/llvm/test/tools/llvm-profdata/sample-fs.test
index d3d038b17ab70..2146556b81568 100644
--- a/llvm/test/tools/llvm-profdata/sample-fs.test
+++ b/llvm/test/tools/llvm-profdata/sample-fs.test
@@ -1,8 +1,8 @@
 Basic tests for sample profiles using fs discriminators.
 
 1- Show command and keep all the discrimiantor bits
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs | FileCheck %s --check-prefix=SHOW1
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast | FileCheck %s --check-prefix=SHOW1
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs | FileCheck %s --check-prefix=SHOW1
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass PassLast | FileCheck %s --check-prefix=SHOW1
 SHOW1: Function: main: 6436, 0, 6 sampled lines
 SHOW1: Samples collected in the function's body {
 SHOW1:   4: 534
@@ -14,7 +14,7 @@ SHOW1:   5.738209025: 2150
 SHOW1: }
 
 2- Show command and keep only the base discriminator bits
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base | FileCheck %s --check-prefix=SHOW2
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Base | FileCheck %s --check-prefix=SHOW2
 SHOW2: Function: main: 6436, 0, 4 sampled lines
 SHOW2: Samples collected in the function's body {
 SHOW2:   4: 534
@@ -24,7 +24,7 @@ SHOW2:   5.1: 3225
 SHOW2: }
 
 3- Show command and keep only the base discriminator bits and first pass of FS discriminator
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 | FileCheck %s --check-prefix=SHOW3
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Pass1 | FileCheck %s --check-prefix=SHOW3
 Function: main: 6436, 0, 6 sampled lines
 SHOW3: Samples collected in the function's body {
 SHOW3:   4: 534
@@ -36,23 +36,23 @@ SHOW3:   5.11521: 2150
 SHOW3: }
 
 4- Merge command and keep all the discrimiantor bits
-RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast --binary -o - | llvm-profdata show --sample - -o %t1-binary_1
-RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs --binary -o - | llvm-profdata show --sample - -o %t1-binary_2
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -o %t1-text
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass PassLast --binary -o - | llvm-profdata show --sample - -o %t1-binary_1
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext --profile-isfs --binary -o - | llvm-profdata show --sample - -o %t1-binary_2
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs -o %t1-text
 RUN: diff %t1-binary_1 %t1-text
 RUN: diff %t1-binary_2 %t1-text
 
 2- Merge command and keep only the base discriminator bits
-RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base --binary -o - | llvm-profdata show --sample - -o %t2-binary
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base -o %t2-text
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Base --binary -o - | llvm-profdata show --sample - -o %t2-binary
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Base -o %t2-text
 RUN: diff %t2-binary %t2-text
 
 3- Merge command and keep only the base discriminator bits and first pass of FS discriminator
-RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 --binary -o - | llvm-profdata show --sample - -o %t3-binary
-RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 -o %t3-text
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Pass1 --binary -o - | llvm-profdata show --sample - -o %t3-binary
+RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext --profile-isfs --fs-discriminator-pass Pass1 -o %t3-text
 RUN: diff %t3-binary %t3-text
 
 4- ProfileIsFS is set properly in extbinary format from the internal option
-RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs --extbinary -o %t_extbin.afdo
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext --profile-isfs --extbinary -o %t_extbin.afdo
 RUN: llvm-profdata show --sample --show-sec-info-only %t_extbin.afdo | FileCheck %s --check-prefix=ISFSSET
 ISFSSET: Flags: {fs-discriminator}
diff --git a/llvm/test/tools/llvm-profdata/sample-hot-func-list.test b/llvm/test/tools/llvm-profdata/sample-hot-func-list.test
index 91a8d817d55f6..402923fce07b2 100644
--- a/llvm/test/tools/llvm-profdata/sample-hot-func-list.test
+++ b/llvm/test/tools/llvm-profdata/sample-hot-func-list.test
@@ -21,7 +21,7 @@
 ; CS-NEXT: 500853 (25.44%)        74946             20              main:3.1 @ _Z5funcBi:1 @ _Z8funcLeafi
 
 
-; RUN: llvm-profdata show --sample --topn=2 %S/Inputs/sample-hot-func-list.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=TOPN
+; RUN: llvm-profdata show --sample --topn 2 %S/Inputs/sample-hot-func-list.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=TOPN
 
 ;      TOPN:8 out of 10 functions with profile (80.00%) are considered hot functions (max sample >= 470).
 ; TOPN-NEXT:355251 out of 356026 profile counts (99.78%) are from hot functions.
@@ -29,7 +29,7 @@
 ; TOPN-NEXT: 184019 (51.69%)        2300              534             main
 ; TOPN-NEXT: 97401 (27.36%)         10640             3035            Func3
 
-; RUN: llvm-profdata show --sample --topn=1 %S/Inputs/cs-sample.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CS-TOPN
+; RUN: llvm-profdata show --sample --topn 1 %S/Inputs/cs-sample.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CS-TOPN
 
 ;      CS-TOPN:2 out of 8 functions with profile (25.00%) are considered hot functions (max sample >= 23324).
 ; CS-TOPN-NEXT:1968152 out of 1968919 profile counts (99.96%) are from hot functions.
diff --git a/llvm/test/tools/llvm-profdata/sample-overlap.test b/llvm/test/tools/llvm-profdata/sample-overlap.test
index 859b705e5f3bd..36123f7fac3b2 100644
--- a/llvm/test/tools/llvm-profdata/sample-overlap.test
+++ b/llvm/test/tools/llvm-profdata/sample-overlap.test
@@ -40,7 +40,7 @@
 ; OVERLAP1:    hot blocks unique in base profile: 0
 ; OVERLAP1:    hot blocks unique in test profile: 0
 
-; RUN: llvm-profdata overlap --sample --similarity-cutoff=800000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-2.proftext | FileCheck %s --check-prefix=OVERLAP2  --match-full-lines --strict-whitespace
+; RUN: llvm-profdata overlap --sample --similarity-cutoff 800000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-2.proftext | FileCheck %s --check-prefix=OVERLAP2  --match-full-lines --strict-whitespace
 ; OVERLAP2:Program level:
 ; OVERLAP2:  Whole program profile similarity: 63.720%
 ; OVERLAP2:  Whole program sample overlap: 29.649%
@@ -65,7 +65,7 @@
 ; OVERLAP2:78.15%         26.29%         48.09%       9.98%     0.00%         0.00%         10896          1087           main
 ; OVERLAP2:10.31%         34.76%         75.55%       100.00%   0.00%         0.00%         1437           1437           _Z3bari
 
-; RUN: llvm-profdata overlap --sample --value-cutoff=1000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-3.proftext | FileCheck %s --check-prefix=OVERLAP3  --match-full-lines --strict-whitespace
+; RUN: llvm-profdata overlap --sample --value-cutoff 1000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-3.proftext | FileCheck %s --check-prefix=OVERLAP3  --match-full-lines --strict-whitespace
 ; OVERLAP3:Program level:
 ; OVERLAP3:  Whole program profile similarity: 14.301%
 ; OVERLAP3:  Whole program sample overlap: 6.040%
@@ -90,7 +90,7 @@
 ; OVERLAP3:10.31%         11.02%         99.29%       100.00%   0.00%         0.00%         1437           1437           _Z3bari
 ; OVERLAP3:0.00%          83.54%         0.00%        0.00%     0.00%         100.00%       0              10896          main2
 
-; RUN: llvm-profdata overlap --sample --function=main %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-4.proftext | FileCheck %s --check-prefix=OVERLAP4  --match-full-lines --strict-whitespace
+; RUN: llvm-profdata overlap --sample --function main %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-4.proftext | FileCheck %s --check-prefix=OVERLAP4  --match-full-lines --strict-whitespace
 ; OVERLAP4:Program level:
 ; OVERLAP4:  Whole program profile similarity: 17.302%
 ; OVERLAP4:  Whole program sample overlap: 8.134%
diff --git a/llvm/test/tools/llvm-profdata/sample-profile-basic.test b/llvm/test/tools/llvm-profdata/sample-profile-basic.test
index 0b0d37aac36cf..bf501f42883f2 100644
--- a/llvm/test/tools/llvm-profdata/sample-profile-basic.test
+++ b/llvm/test/tools/llvm-profdata/sample-profile-basic.test
@@ -9,7 +9,7 @@ SHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines
 SHOW1-DAG: 1: 1437
 
 2- Show only bar
-RUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
+RUN: llvm-profdata show --sample --function _Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
 SHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines
 SHOW2: 1: 1437
 SHOW2-NOT: Function: main: 184019, 0, 7 sampled lines
diff --git a/llvm/test/tools/llvm-profdata/sample-profile-json.test b/llvm/test/tools/llvm-profdata/sample-profile-json.test
index 9e96693faace6..d114b6056ed6e 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 --show-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/test/tools/llvm-profdata/sample-remap.test b/llvm/test/tools/llvm-profdata/sample-remap.test
index 8e69c45726635..a7098738695bd 100644
--- a/llvm/test/tools/llvm-profdata/sample-remap.test
+++ b/llvm/test/tools/llvm-profdata/sample-remap.test
@@ -1,2 +1,2 @@
-; RUN: llvm-profdata merge -sample -text %S/Inputs/sample-remap.proftext -r %S/Inputs/sample-remap.remap -o %t.output
+; RUN: llvm-profdata merge --sample --text %S/Inputs/sample-remap.proftext -r %S/Inputs/sample-remap.remap -o %t.output
 ; RUN: diff -b %S/Inputs/sample-remap.expected %t.output
diff --git a/llvm/test/tools/llvm-profdata/sample-split-layout.test b/llvm/test/tools/llvm-profdata/sample-split-layout.test
index 51091e9f25c02..ea6193b840b3b 100644
--- a/llvm/test/tools/llvm-profdata/sample-split-layout.test
+++ b/llvm/test/tools/llvm-profdata/sample-split-layout.test
@@ -1,6 +1,5 @@
-RUN: llvm-profdata merge --sample --extbinary --split-layout %p/Inputs/sample-profile.proftext -o %t-output
-
-RUN: llvm-profdata merge --sample --text --split-layout %t-output | FileCheck %s
+RUN: llvm-profdata merge --sample --extbinary --split-layout %p/Inputs/sample-profile.proftext -o %t-o 
+RUN: llvm-profdata merge --sample --text --split-layout %t-o | FileCheck %s
 CHECK: main:184019:0
 CHECK-NEXT:  4: 534
 CHECK-NEXT:  4.2: 534
diff --git a/llvm/test/tools/llvm-profdata/sample-summary.test b/llvm/test/tools/llvm-profdata/sample-summary.test
index 310cc8bfb721c..9c1473b96b814 100644
--- a/llvm/test/tools/llvm-profdata/sample-summary.test
+++ b/llvm/test/tools/llvm-profdata/sample-summary.test
@@ -1,4 +1,4 @@
-; RUN: llvm-profdata show -sample -detailed-summary %S/Inputs/sample-profile.proftext | FileCheck %s
+; RUN: llvm-profdata show --sample --detailed-summary %S/Inputs/sample-profile.proftext | FileCheck %s
 
 ; CHECK: Total functions: 3
 ; CHECK-NEXT: Maximum function count: 1437
diff --git a/llvm/test/tools/llvm-profdata/show-instr-level.test b/llvm/test/tools/llvm-profdata/show-instr-level.test
index ed003265e3836..7d85c32b29766 100644
--- a/llvm/test/tools/llvm-profdata/show-instr-level.test
+++ b/llvm/test/tools/llvm-profdata/show-instr-level.test
@@ -1,7 +1,7 @@
 RUN: llvm-profdata merge -o %t_clang.profdata %p/Inputs/clang_profile.proftext
-RUN: llvm-profdata show %t_clang.profdata | FileCheck %s -check-prefix=FE
+RUN: llvm-profdata show %t_clang.profdata | FileCheck %s --check-prefix=FE
 FE: Instrumentation level: Front-end
 
 RUN: llvm-profdata merge -o %t_ir.profdata %p/Inputs/IR_profile.proftext
-RUN: llvm-profdata show %t_ir.profdata | FileCheck %s -check-prefix=IR
+RUN: llvm-profdata show %t_ir.profdata | FileCheck %s --check-prefix=IR
 IR: Instrumentation level: IR
diff --git a/llvm/test/tools/llvm-profdata/show-order-error.proftext b/llvm/test/tools/llvm-profdata/show-order-error.proftext
index 633f1a9949b6f..ff1d3f163d184 100644
--- a/llvm/test/tools/llvm-profdata/show-order-error.proftext
+++ b/llvm/test/tools/llvm-profdata/show-order-error.proftext
@@ -1,4 +1,4 @@
-# RUN: not llvm-profdata order %s --num-test-traces=10 2>&1 | FileCheck %s
+# RUN: not llvm-profdata order %s --num-test-traces 10 2>&1 | FileCheck %s
 
 # CHECK: --num-test-traces must be smaller than the total number of traces
 
diff --git a/llvm/test/tools/llvm-profdata/show-order.proftext b/llvm/test/tools/llvm-profdata/show-order.proftext
index 28eb1b9b42af7..59750b2f42e8b 100644
--- a/llvm/test/tools/llvm-profdata/show-order.proftext
+++ b/llvm/test/tools/llvm-profdata/show-order.proftext
@@ -1,4 +1,4 @@
-# RUN: llvm-profdata order %s --num-test-traces=1 | FileCheck %s
+# RUN: llvm-profdata order %s --num-test-traces 1 | FileCheck %s
 
 # CHECK: # Total area under the page fault curve: 4.000000e+00
 
diff --git a/llvm/test/tools/llvm-profdata/show-prof-info.test b/llvm/test/tools/llvm-profdata/show-prof-info.test
index 2b38dee5d865e..13eaf7d26e423 100644
--- a/llvm/test/tools/llvm-profdata/show-prof-info.test
+++ b/llvm/test/tools/llvm-profdata/show-prof-info.test
@@ -1,7 +1,7 @@
 REQUIRES: zlib
-; 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: 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: llvm-profdata show --sample --show-sec-info-only %t.1.output >> %t.txt
 ; RUN: FileCheck %s --input-file=%t.txt
 ; CHECK: [[FILESIZE:.*]]
 ; To check llvm-profdata shows the correct flags for ProfileSummarySection.
diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test
index 4a394d7bce5c5..982887d213ea4 100644
--- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test
+++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test
@@ -3,9 +3,9 @@ with flattening.
 
 Test bar.cc:bar's counters will be set to PseudoHot.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/flatten_sample.proftext \
+RUN:     --supplement-instr-with-sample %p/Inputs/flatten_sample.proftext \
 RUN:     %p/Inputs/flatten_instr.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FLATTEN
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=FLATTEN
 
 FLATTEN:  foo:
 FLATTEN-NEXT:    Hash: 0x0000000000000457
diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test
index 2d500df28a92b..9bca631bb70f2 100644
--- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test
+++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test
@@ -1,16 +1,16 @@
 Some basic tests for supplementing instrumentation profile with sample profile for static funcs.
 
-RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/NoFUnique.proftext -o %t1
-RUN: llvm-profdata show -function=foo -counts %t1 | FileCheck %s
+RUN: llvm-profdata merge --supplement-instr-with-sample %p/Inputs/NoFUnique.afdotext --suppl-min-size-threshold 2 %p/Inputs/NoFUnique.proftext -o %t1
+RUN: llvm-profdata show --function foo --counts %t1 | FileCheck %s
 
-RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/FUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/FUnique.proftext -o %t2
-RUN: llvm-profdata show -function=foo -counts %t2 | FileCheck %s
+RUN: llvm-profdata merge --supplement-instr-with-sample %p/Inputs/FUnique.afdotext --suppl-min-size-threshold 2 %p/Inputs/FUnique.proftext -o %t2
+RUN: llvm-profdata show --function foo --counts %t2 | FileCheck %s
 
-RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/FUnique.proftext -o %t3
-RUN: llvm-profdata show -function=foo -counts %t3 | FileCheck %s
+RUN: llvm-profdata merge --supplement-instr-with-sample %p/Inputs/NoFUnique.afdotext --suppl-min-size-threshold 2 %p/Inputs/FUnique.proftext -o %t3
+RUN: llvm-profdata show --function foo --counts %t3 | FileCheck %s
 
-RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/FUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/NoFUnique.proftext -o %t4
-RUN: llvm-profdata show -function=foo -counts %t4 | FileCheck %s
+RUN: llvm-profdata merge --supplement-instr-with-sample %p/Inputs/FUnique.afdotext --suppl-min-size-threshold 2 %p/Inputs/NoFUnique.proftext -o %t4
+RUN: llvm-profdata show --function foo --counts %t4 | FileCheck %s
 
 CHECK: Counters: 3    <PseudoHot>
 CHECK-NEXT: Instrumentation level:
diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
index c22646e45849e..291e0114a0eca 100644
--- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -2,9 +2,9 @@ Some basic tests for supplementing instrumentation profile with sample profile.
 
 Test all of goo's counters will be set to PseudoHot.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
-RUN:     -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1
+RUN:     --supplement-instr-with-sample %p/Inputs/mix_sample.proftext \
+RUN:     --suppl-min-size-threshold 0 %p/Inputs/mix_instr.proftext -o %t
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=MIX1
 
 MIX1: foo:
 MIX1-NEXT: Hash: 0x0000000000000007
@@ -22,10 +22,10 @@ MIX1-NEXT: Block counts: [3000, 1000, 2000, 500]
 
 Test when the zero counter ratio of foo is higher than zero-counter-threshold.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
-RUN:     -suppl-min-size-threshold=0 -zero-counter-threshold=0.5 \
-RUN:     -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2
+RUN:     --supplement-instr-with-sample %p/Inputs/mix_sample.proftext \
+RUN:     --suppl-min-size-threshold 0 --zero-counter-threshold 0.5 \
+RUN:     --instr-prof-cold-threshold 30 %p/Inputs/mix_instr.proftext -o %t
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=MIX2
 
 MIX2: foo:
 MIX2-NEXT: Hash: 0x0000000000000007
@@ -44,10 +44,10 @@ MIX2-NEXT: Block counts: [3000, 1000, 2000, 500]
 
 Test when the zero counter ratio of foo is lower than zero-counter-threshold.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
-RUN:     -suppl-min-size-threshold=0 -zero-counter-threshold=0.7 \
-RUN:     -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3
+RUN:     --supplement-instr-with-sample %p/Inputs/mix_sample.proftext \
+RUN:     --suppl-min-size-threshold 0 --zero-counter-threshold 0.7 \
+RUN:     --instr-prof-cold-threshold 30 %p/Inputs/mix_instr.proftext -o %t
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=MIX3
 
 MIX3: foo:
 MIX3-NEXT: Hash: 0x0000000000000007
@@ -66,10 +66,10 @@ MIX3-NEXT: Block counts: [3000, 1000, 2000, 500]
 Test foo's profile won't be adjusted because its size is smaller
 than suppl-min-size-threshold.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
-RUN:     -suppl-min-size-threshold=2 -zero-counter-threshold=0.7 \
-RUN:     -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
-RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
+RUN:     --supplement-instr-with-sample %p/Inputs/mix_sample.proftext \
+RUN:     --suppl-min-size-threshold 2 --zero-counter-threshold 0.7 \
+RUN:     --instr-prof-cold-threshold 30 %p/Inputs/mix_instr_small.proftext -o %t
+RUN: llvm-profdata show %t --all-functions --counts | FileCheck %s --check-prefix=MIX4
 
 MIX4: foo:
 MIX4-NEXT: Hash: 0x0000000000000007
@@ -87,9 +87,9 @@ MIX4-NEXT: Block counts: [0]
 
 Test profile summary won't be affected by pseudo counters.
 RUN: llvm-profdata merge \
-RUN:     -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
-RUN:     -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
-RUN: llvm-profdata show %t -detailed-summary | FileCheck %s --check-prefix=MIX5
+RUN:     --supplement-instr-with-sample %p/Inputs/mix_sample.proftext \
+RUN:     --suppl-min-size-threshold 0 %p/Inputs/mix_instr.proftext -o %t
+RUN: llvm-profdata show %t --detailed-summary | FileCheck %s --check-prefix=MIX5
 
 MIX5: Instrumentation level: IR
 MIX5-NEXT: Total functions: 2
diff --git a/llvm/test/tools/llvm-profdata/text-dump.test b/llvm/test/tools/llvm-profdata/text-dump.test
index 22acb6e23039a..e11e05e356ce6 100644
--- a/llvm/test/tools/llvm-profdata/text-dump.test
+++ b/llvm/test/tools/llvm-profdata/text-dump.test
@@ -1,20 +1,20 @@
 Basic tests for testing text dump functions.
 
-RUN: llvm-profdata show --all-functions -counts --text %p/Inputs/basic.proftext > %t-basic.proftext1
+RUN: llvm-profdata show --all-functions --counts --text %p/Inputs/basic.proftext > %t-basic.proftext1
 RUN: llvm-profdata merge -o %t-basic.proftext2 --text  %p/Inputs/basic.proftext
 RUN: llvm-profdata merge --text %p/Inputs/basic.proftext | diff %t-basic.proftext2 -
 
-RUN: llvm-profdata merge -binary -o %t-basic.profdata1 %t-basic.proftext1
+RUN: llvm-profdata merge --binary -o %t-basic.profdata1 %t-basic.proftext1
 RUN: llvm-profdata merge -o %t-basic.profdata2 %t-basic.proftext2
 
-RUN: llvm-profdata show --all-functions -counts  %t-basic.profdata1 > %t-basic.dump3
-RUN: llvm-profdata show --all-functions -counts  %t-basic.profdata2 > %t-basic.dump4
+RUN: llvm-profdata show --all-functions --counts  %t-basic.profdata1 > %t-basic.dump3
+RUN: llvm-profdata show --all-functions --counts  %t-basic.profdata2 > %t-basic.dump4
 
-RUN: llvm-profdata merge -text -o %t-basic.proftext5 %t-basic.profdata1
-RUN: llvm-profdata merge -text -o %t-basic.proftext6 %t-basic.profdata2
+RUN: llvm-profdata merge --text -o %t-basic.proftext5 %t-basic.profdata1
+RUN: llvm-profdata merge --text -o %t-basic.proftext6 %t-basic.profdata2
 
 RUN: diff %t-basic.dump3 %t-basic.dump4
 RUN: diff %t-basic.proftext5 %t-basic.proftext6
 
-RUN: not llvm-profdata merge -gcc -o %t-basic-profdata3 %t-basic.proftext2 2>&1 | FileCheck %s --check-prefix=UNKNOWN
+RUN: not llvm-profdata merge --gcc -o %t-basic-profdata3 %t-basic.proftext2 2>&1 | FileCheck %s --check-prefix=UNKNOWN
 UNKNOWN: unknown format is specified
diff --git a/llvm/test/tools/llvm-profdata/text-format-errors.test b/llvm/test/tools/llvm-profdata/text-format-errors.test
index 4a75edd70ff40..309d14ffb6be9 100644
--- a/llvm/test/tools/llvm-profdata/text-format-errors.test
+++ b/llvm/test/tools/llvm-profdata/text-format-errors.test
@@ -5,7 +5,7 @@ RUN: not llvm-profdata show %p/Inputs/invalid-count-later.proftext 2>&1 | FileCh
 INVALID-COUNT-LATER-SHOW: error: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data
 
 RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE
-RUN: not llvm-profdata merge -failure-mode=all %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE
+RUN: not llvm-profdata merge --failure-mode all %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE
 INVALID-COUNT-LATER-MERGE: warning: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data
 INVALID-COUNT-LATER-MERGE-NEXT: warning: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data
 INVALID-COUNT-LATER-MERGE-NEXT: error: no profile can be merged
diff --git a/llvm/test/tools/llvm-profdata/trace-limit.proftext b/llvm/test/tools/llvm-profdata/trace-limit.proftext
index 6b4f974add169..3ab0f19d6c5d4 100644
--- a/llvm/test/tools/llvm-profdata/trace-limit.proftext
+++ b/llvm/test/tools/llvm-profdata/trace-limit.proftext
@@ -1,14 +1,14 @@
-# RUN: llvm-profdata merge --temporal-profile-max-trace-length=0 %s -o %t.profdata
+# RUN: llvm-profdata merge --temporal-profile-max-trace-length 0 %s -o %t.profdata
 # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE
 
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t.profdata
-# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 --temporal-profile-max-trace-length=0 %t.profdata -o %t.profdata
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s -o %t.profdata
+# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 --temporal-profile-max-trace-length 0 %t.profdata -o %t.profdata
 # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE
 
-# RUN: llvm-profdata merge --temporal-profile-max-trace-length=2 %s -o %t.profdata
+# RUN: llvm-profdata merge --temporal-profile-max-trace-length 2 %s -o %t.profdata
 # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,SOME
 
-# RUN: llvm-profdata merge --temporal-profile-max-trace-length=1000 %s -o %t.profdata
+# RUN: llvm-profdata merge --temporal-profile-max-trace-length 1000 %s -o %t.profdata
 # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,ALL
 
 # NONE: Temporal Profile Traces (samples=0 seen=0):
diff --git a/llvm/test/tools/llvm-profdata/value-prof.proftext b/llvm/test/tools/llvm-profdata/value-prof.proftext
index ec09e40e496d7..a6bfff56c9e28 100644
--- a/llvm/test/tools/llvm-profdata/value-prof.proftext
+++ b/llvm/test/tools/llvm-profdata/value-prof.proftext
@@ -1,7 +1,7 @@
-# RUN: llvm-profdata show -ic-targets  -all-functions %s | FileCheck %s --check-prefixes=ICTXT,ICSUM
-# RUN: llvm-profdata show -ic-targets -counts -text -all-functions %s | FileCheck %s --check-prefix=ICTEXT
+# RUN: llvm-profdata show --ic-targets  --all-functions %s | FileCheck %s --check-prefixes=ICTXT,ICSUM
+# RUN: llvm-profdata show --ic-targets --counts --text --all-functions %s | FileCheck %s --check-prefix=ICTEXT
 # RUN: llvm-profdata merge -o %t.profdata  %s
-# RUN: llvm-profdata show -ic-targets  -all-functions %t.profdata | FileCheck %s --check-prefixes=IC,ICSUM
+# RUN: llvm-profdata show --ic-targets  --all-functions %t.profdata | FileCheck %s --check-prefixes=IC,ICSUM
 
 foo
 # Func Hash:
diff --git a/llvm/test/tools/llvm-profdata/vtable-value-prof.test b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
index 5ed4a356e1041..185f630283a0a 100644
--- a/llvm/test/tools/llvm-profdata/vtable-value-prof.test
+++ b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
@@ -4,15 +4,15 @@
 RUN: llvm-profdata merge --keep-vtable-symbols %S/Inputs/vtable-value-prof.proftext -o %t/indexed.profdata
 
 ; Show indexed profiles
-RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t/indexed.profdata | FileCheck %s --check-prefix=INDEXED
+RUN: llvm-profdata show --function main --ic-targets --show-vtables %t/indexed.profdata | FileCheck %s --check-prefix=INDEXED
 
 ; Show text profiles
-RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT
+RUN: llvm-profdata show --function main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT
 
 ; Convert indexed profiles to its textual output and show it.
 RUN: llvm-profdata merge --keep-vtable-symbols --text -o %t/text-from-indexed.proftext %t/indexed.profdata
-RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t/text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED
-RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %t/text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
+RUN: llvm-profdata show --function main --ic-targets --show-vtables %t/text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED
+RUN: llvm-profdata show --function main --ic-targets --show-vtables --text %t/text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
 
 INDEXED:      Counters:
 INDEXED-NEXT:   main:
diff --git a/llvm/test/tools/llvm-profdata/weight-instr.test b/llvm/test/tools/llvm-profdata/weight-instr.test
index 3f6979a071d29..762d8da0c30de 100644
--- a/llvm/test/tools/llvm-profdata/weight-instr.test
+++ b/llvm/test/tools/llvm-profdata/weight-instr.test
@@ -1,14 +1,14 @@
 Tests for weighted merge of instrumented profiles.
 
 1- Merge the foo and bar profiles with unity weight and verify the combined output
-RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata -weighted-input=1,%p/Inputs/weight-instr-foo.profdata -o %t
-RUN: llvm-profdata show -instr -all-functions %t > %t.out1
+RUN: llvm-profdata merge --instr --weighted-input 1,%p/Inputs/weight-instr-bar.profdata --weighted-input 1,%p/Inputs/weight-instr-foo.profdata -o %t
+RUN: llvm-profdata show --instr --all-functions %t > %t.out1
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-1 < %t.out1
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-2 < %t.out1
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-3 < %t.out1
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-4 < %t.out1
-RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
-RUN: llvm-profdata show -instr -all-functions %t > %t.out2
+RUN: llvm-profdata merge --instr --weighted-input 1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t
+RUN: llvm-profdata show --instr --all-functions %t > %t.out2
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-1 < %t.out2
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-2 < %t.out2
 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-3 < %t.out2
@@ -36,8 +36,8 @@ RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-4 < %t.out2
 1X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296
 
 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
-RUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t
-RUN: llvm-profdata show -instr -all-functions %t > %t.out3
+RUN: llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input 5,%p/Inputs/weight-instr-foo.profdata -o %t
+RUN: llvm-profdata show --instr --all-functions %t > %t.out3
 RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-1 < %t.out3
 RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-2 < %t.out3
 RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-3 < %t.out3
@@ -65,17 +65,17 @@ RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-4 < %t.out3
 3X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480
 
 3- Bad merge: invalid weight
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=-5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input 0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input 0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input -5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input ,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/weight-instr-bar.profdata --weighted-input %p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
 INVALID_WEIGHT: error: input weight must be a positive integer
 
 4- Bad merge: input path does not exist
-RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/does-not-exist.profdata -weighted-input=2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT
+RUN: not llvm-profdata merge --instr --weighted-input 3,%p/Inputs/does-not-exist.profdata --weighted-input 2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck --DMSG=%errc_ENOENT %s --check-prefix=INVALID_INPUT
 INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: [[MSG]]
 
 5- No inputs
-RUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
-NO_INPUT: error: no input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help
+RUN: not llvm-profdata merge --instr -o %t.out 2>&1 | FileCheck %s --check-prefix=NO_INPUT
+NO_INPUT: error: no input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge --help
diff --git a/llvm/test/tools/llvm-profdata/weight-sample.test b/llvm/test/tools/llvm-profdata/weight-sample.test
index 4c28a4a1ebf40..312cc336acd54 100644
--- a/llvm/test/tools/llvm-profdata/weight-sample.test
+++ b/llvm/test/tools/llvm-profdata/weight-sample.test
@@ -1,8 +1,8 @@
 Tests for weighted merge of sample profiles.
 
 1- Merge the foo and bar profiles with unity weight and verify the combined output
-RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext -weighted-input=1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
-RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
+RUN: llvm-profdata merge --sample --text --weighted-input 1,%p/Inputs/weight-sample-bar.proftext --weighted-input 1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s --check-prefix=1X_1X_WEIGHT
+RUN: llvm-profdata merge --sample --text --weighted-input 1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s --check-prefix=1X_1X_WEIGHT
 1X_1X_WEIGHT-DAG: foo:1763288:35327
 1X_1X_WEIGHT-DAG:  7: 35327
 1X_1X_WEIGHT-DAG:  8: 35327
@@ -21,7 +21,7 @@ RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample
 1X_1X_WEIGHT-DAG:  25: 36666
 
 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
-RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT
+RUN: llvm-profdata merge --sample --text --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input 5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s --check-prefix=3X_5X_WEIGHT
 3X_5X_WEIGHT-DAG: foo:8816440:176635
 3X_5X_WEIGHT-DAG:  7: 176635
 3X_5X_WEIGHT-DAG:  8: 176635
@@ -40,17 +40,17 @@ RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample
 3X_5X_WEIGHT-DAG:  25: 109998
 
 3- Bad merge: invalid weight
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=-5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input 0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input 0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input -5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input ,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/weight-sample-bar.proftext --weighted-input %p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID_WEIGHT
 INVALID_WEIGHT: error: input weight must be a positive integer
 
 4- Bad merge: input path does not exist
-RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/does-not-exist.proftext -weighted-input=2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT
+RUN: not llvm-profdata merge --sample --weighted-input 3,%p/Inputs/does-not-exist.proftext --weighted-input 2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck --DMSG=%errc_ENOENT %s --check-prefix=INVALID_INPUT
 INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.proftext: [[MSG]]
 
 5- No inputs
-RUN: not llvm-profdata merge -sample -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT
-NO_INPUT: {{.*}}: no input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help
+RUN: not llvm-profdata merge --sample -o %t.out 2>&1 | FileCheck %s --check-prefix=NO_INPUT
+NO_INPUT: {{.*}}: no input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge --help
diff --git a/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test b/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test
index dbef3aac66786..37ca02ad91717 100644
--- a/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test
+++ b/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test
@@ -3,7 +3,7 @@ RUN: --data-access-perftrace=%p/Inputs/pie-dap-perf.txt  \
 RUN: --binary=%p/Inputs/dap-pie.bin --format=text --pid=1725662 \
 RUN: -ignore-stack-samples -use-dwarf-correlation -o %t.afdo
 
-RUN: llvm-profdata show --sample --function=_Z9loop_funciii %t.afdo 2>&1 | FileCheck %s --dump-input=always
+RUN: llvm-profdata show --sample --function _Z9loop_funciii %t.afdo 2>&1 | FileCheck %s --dump-input=always
 
 RUN: not llvm-profgen --perfscript=%p/Inputs/pie-lbr-perf.script \
 RUN: --data-access-perftrace=%p/Inputs/pie-dap-perf.txt  \
diff --git a/llvm/test/tools/llvm-profgen/afdo-with-vtable.test b/llvm/test/tools/llvm-profgen/afdo-with-vtable.test
index 799d59d56526e..f703fea2c8cd9 100644
--- a/llvm/test/tools/llvm-profgen/afdo-with-vtable.test
+++ b/llvm/test/tools/llvm-profgen/afdo-with-vtable.test
@@ -2,7 +2,7 @@ RUN: llvm-profgen --perfscript=%p/Inputs/lbr-perf-for-dap.script --data-access-p
 RUN:  --binary=%p/Inputs/dap.bin --format=text --pid=3446532 \
 RUN: -ignore-stack-samples -use-dwarf-correlation -o %t.afdo
 
-RUN: llvm-profdata show --sample --function=_Z9loop_funciii %t.afdo 2>&1 | FileCheck %s
+RUN: llvm-profdata show --sample --function _Z9loop_funciii %t.afdo 2>&1 | FileCheck %s
 
 RUN: not llvm-profgen --perfscript=%p/Inputs/lbr-perf-for-dap.script --data-access-perftrace=%p/Inputs/dap-perf-trace.txt \
 RUN:  --binary=%p/Inputs/dap.bin --format=text --pid=3446532 \
diff --git a/llvm/test/tools/llvm-profgen/cs-extbinary.test b/llvm/test/tools/llvm-profgen/cs-extbinary.test
index 654b7d4cf2fa4..d5e2b6a9a98e3 100644
--- a/llvm/test/tools/llvm-profgen/cs-extbinary.test
+++ b/llvm/test/tools/llvm-profgen/cs-extbinary.test
@@ -1,14 +1,14 @@
 ; test for dwarf-based cs profile
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/recursion-compression-noprobe.perfscript --binary=%S/Inputs/recursion-compression-noprobe.perfbin --output=%t1 --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
-; RUN: llvm-profdata merge --sample --text --output=%t2 %t1
+; RUN: llvm-profdata merge --sample --text -o %t2 %t1
 ; RUN: FileCheck %S/recursion-compression-noprobe.test --input-file %t2
-; RUN: llvm-profdata merge --sample --extbinary --output=%t3 %t2 && llvm-profdata merge --sample --text --output=%t4 %t3
+; RUN: llvm-profdata merge --sample --extbinary -o %t3 %t2 && llvm-profdata merge --sample --text -o %t4 %t3
 ; RUN: diff -b %t2 %t4
 
 
 ; test for probe-based cs profile
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t5 --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
-; RUN: llvm-profdata merge --sample --text --output=%t6 %t5
+; RUN: llvm-profdata merge --sample --text -o %t6 %t5
 ; RUN: FileCheck %S/recursion-compression-pseudoprobe.test --input-file %t6
-; RUN: llvm-profdata merge --sample --extbinary --output=%t7 %t6 && llvm-profdata merge --sample --text --output=%t8 %t7
+; RUN: llvm-profdata merge --sample --extbinary -o %t7 %t6 && llvm-profdata merge --sample --text -o %t8 %t7
 ; RUN: diff -b %t6 %t8
diff --git a/llvm/test/tools/llvm-profgen/cs-preinline.test b/llvm/test/tools/llvm-profgen/cs-preinline.test
index b48d63cf75b77..d5f11ff142dd4 100644
--- a/llvm/test/tools/llvm-profgen/cs-preinline.test
+++ b/llvm/test/tools/llvm-profgen/cs-preinline.test
@@ -21,15 +21,15 @@
 
 ; Test preInlined flat is set for extbinary profiles with preinliner on.
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --csspgo-preinliner=1 --gen-cs-nested-profile=0 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=45 --output=%t2.prof
-; RUN: llvm-profdata show --sample -show-sec-info-only %t2.prof | FileCheck %s -check-prefix=CHECK-PREINL-FLAG
+; RUN: llvm-profdata show --sample --show-sec-info-only %t2.prof | FileCheck %s --check-prefix=CHECK-PREINL-FLAG
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin  --csspgo-preinliner=1 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=45 --output=%t5.prof --gen-cs-nested-profile=1
-; RUN: llvm-profdata show --sample -show-sec-info-only %t5.prof | FileCheck %s -check-prefix=CHECK-PREINL-FLAG
+; RUN: llvm-profdata show --sample --show-sec-info-only %t5.prof | FileCheck %s --check-prefix=CHECK-PREINL-FLAG
 
 ; Test preInlined flat is set when converted from a text profile that has "ShouldInline" contexts.
 ; RUN: llvm-profdata merge --sample %t2 -o %t2.prof --extbinary
-; RUN: llvm-profdata show --sample -show-sec-info-only %t2.prof | FileCheck %s -check-prefix=CHECK-PREINL-FLAG
+; RUN: llvm-profdata show --sample --show-sec-info-only %t2.prof | FileCheck %s --check-prefix=CHECK-PREINL-FLAG
 ; RUN: llvm-profdata merge --sample %t5 -o %t5.prof --extbinary
-; RUN: llvm-profdata show --sample -show-sec-info-only %t5.prof | FileCheck %s -check-prefix=CHECK-PREINL-FLAG
+; RUN: llvm-profdata show --sample --show-sec-info-only %t5.prof | FileCheck %s --check-prefix=CHECK-PREINL-FLAG
 
 
 ; CHECK-DEFAULT:     [main:1 @ foo]:309:0
diff --git a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
index 5f8d89f7ba8e7..a2805f98ab5f2 100644
--- a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
+++ b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
@@ -6,7 +6,7 @@
 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-STRIP-CTX
 
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --profile-summary-cold-count=0 --populate-profile-symbol-list=1 --csspgo-preinliner=0 --gen-cs-nested-profile=0
-; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
+; RUN: llvm-profdata show --show-prof-sym-list --sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
 
 ; CHECK-SYM-LIST: Dump profile symbol list
 ; CHECK-SYM-LIST: bar
diff --git a/llvm/test/tools/llvm-profgen/inline-noprobe2.test b/llvm/test/tools/llvm-profgen/inline-noprobe2.test
index e19d991f0f1c4..ab696dd13162e 100644
--- a/llvm/test/tools/llvm-profgen/inline-noprobe2.test
+++ b/llvm/test/tools/llvm-profgen/inline-noprobe2.test
@@ -6,7 +6,7 @@
 ; RUN: FileCheck %s --input-file %t1 --check-prefix=CHECK
 
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --populate-profile-symbol-list=1
-; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
+; RUN: llvm-profdata show --show-prof-sym-list --sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
 
 ; CHECK-EXT-ADDR:      2
 ; CHECK-EXT-ADDR-NEXT: 400870-400870:2
diff --git a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
index f4682787553d2..80ac402c1b20d 100644
--- a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
+++ b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
@@ -13,9 +13,9 @@
 
 ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noinline-cs-noprobe.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t1 --profile-summary-cold-count=0
 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/noinline-cs-noprobe.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t2 --profile-summary-cold-count=0 -use-md5
-; RUN: llvm-profdata show --sample -show-sec-info-only %t2 | FileCheck %s --check-prefix=CHECK-MD5
-; RUN: llvm-profdata show --sample -detailed-summary --function=dummy %t1 > %t.summary
-; RUN: llvm-profdata show --sample -detailed-summary --function=dummy %t2 > %t2.summary
+; RUN: llvm-profdata show --sample --show-sec-info-only %t2 | FileCheck %s --check-prefix=CHECK-MD5
+; RUN: llvm-profdata show --sample --detailed-summary --function dummy %t1 > %t.summary
+; RUN: llvm-profdata show --sample --detailed-summary --function dummy %t2 > %t2.summary
 ; RUN: diff -b %t.summary %t2.summary
 
 
diff --git a/llvm/tools/llvm-profdata/Opts.td b/llvm/tools/llvm-profdata/Opts.td
index 5244e9638ff16..e147b60a9b062 100644
--- a/llvm/tools/llvm-profdata/Opts.td
+++ b/llvm/tools/llvm-profdata/Opts.td
@@ -22,359 +22,346 @@ def Merge : SubCommand<"merge",
                        "https://llvm.org/docs/CommandGuide/llvm-profdata.html"
                        "#profdata-merge">;
 
-def help : Flag<["-","--"], "help", [Show, Order, Overlap, Merge]>,
-           HelpText<"Display this help">;
-def help_hidden : Flag<["--"], "help-hidden", [Show, Order, Overlap, Merge]>,
-                  HelpText<"Display all help, including hidden options">;
-def version : Flag<["--"], "version", [Show, Order, Overlap, Merge]>,
-              HelpText<"Display the version">;
-
-def output : JoinedOrSeparate<["-","--"], "output",
+def help : Flag<["--"], "help">, HelpText<"Display this help">;
+def version : Flag<["--"], "version">, HelpText<"Display the version">;
+
+def output : JoinedOrSeparate<["--"], "output",
                                [Show, Order, Overlap, Merge]>,
              MetaVarName<"<output>">,
              HelpText<"Output file">;
 def : JoinedOrSeparate<["-"], "o", [Show, Order, Overlap, Merge]>,
      Alias<output>, HelpText<"Alias for --output">;
 
-def instr : Flag<["-","--"], "instr", [Show, Overlap, Merge]>,
+def instr : Flag<["--"], "instr", [Show, Overlap, Merge]>,
             HelpText<"Instrumentation profile (default)">;
-def sample : Flag<["-","--"], "sample", [Show, Overlap, Merge]>,
+def sample : Flag<["--"], "sample", [Show, Overlap, Merge]>,
              HelpText<"Sample profile">;
-def memory : Flag<["-","--"], "memory", [Show]>,
+def memory : Flag<["--"], "memory", [Show]>,
              HelpText<"MemProf memory access profile">;
 
 def max_debug_info_correlation_warnings
-    : JoinedOrSeparate<["-","--"], "max-debug-info-correlation-warnings",
+    : JoinedOrSeparate<["--"], "max-debug-info-correlation-warnings",
                        [Show, Merge]>,
       HelpText<"Maximum number of warnings to emit when correlating profile "
                "from debug info (0 = no limit)">,
       MetaVarName<"<n>">;
 def profiled_binary
-    : JoinedOrSeparate<["-","--"], "profiled-binary", [Show, Merge]>,
+    : JoinedOrSeparate<["--"], "profiled-binary", [Show, Merge]>,
       HelpText<"Path to binary from which the profile was collected.">,
       MetaVarName<"<binary>">;
 def debug_info
-    : JoinedOrSeparate<["-","--"], "debug-info", [Show, Merge]>,
+    : JoinedOrSeparate<["--"], "debug-info", [Show, Merge]>,
       HelpText<"For show, read and extract profile metadata from debug info. "
                "For merge, correlate the raw profile using the provided "
                "debug info.">,
       MetaVarName<"<file>">;
 def binary_file
-    : JoinedOrSeparate<["-","--"], "binary-file", [Merge]>,
+    : JoinedOrSeparate<["--"], "binary-file", [Merge]>,
       HelpText<"Use the provided unstripped binary to correlate the raw "
                "profile.">,
       MetaVarName<"<file>">;
 def debug_file_directory
-    : JoinedOrSeparate<["-","--"], "debug-file-directory",
+    : JoinedOrSeparate<["--"], "debug-file-directory",
                        [Show, Order, Overlap, Merge]>,
       HelpText<"Directories to search for object files by build ID">,
       MetaVarName<"<dir>">;
-def debuginfod : Flag<["-","--"], "debuginfod", [Merge]>,
-                 HelpText<"Enable debuginfod">, Flags<[HelpHidden]>;
-def correlate : JoinedOrSeparate<["-","--"], "correlate",
+def debuginfod : Flag<["--"], "debuginfod", [Merge]>,
+                 HelpText<"Enable debuginfod">;
+def correlate : JoinedOrSeparate<["--"], "correlate",
                                   [Show, Order, Overlap, Merge]>,
                 HelpText<"Use debug-info or binary correlation to correlate "
                          "profiles with build id fetcher">,
                 MetaVarName<"<mode>">;
-def function : JoinedOrSeparate<["-","--"], "function",
+def function : JoinedOrSeparate<["--"], "function",
                                 [Show, Overlap, Merge]>,
                HelpText<"Only functions matching the filter are shown or "
                         "merged.">,
                MetaVarName<"<regex>">;
 
 def weighted_input
-    : JoinedOrSeparate<["-","--"], "weighted-input", [Merge]>,
+    : JoinedOrSeparate<["--"], "weighted-input", [Merge]>,
       HelpText<"<weight>,<filename>">, MetaVarName<"<weight>,<file>">;
-def binary : Flag<["-","--"], "binary", [Merge]>,
+def binary : Flag<["--"], "binary", [Merge]>,
              HelpText<"Binary encoding">;
-def extbinary : Flag<["-","--"], "extbinary", [Merge]>,
+def extbinary : Flag<["--"], "extbinary", [Merge]>,
                 HelpText<"Extensible binary encoding (default)">;
-def text : Flag<["-","--"], "text", [Show, Merge]>,
+def text : Flag<["--"], "text", [Show, Merge]>,
            HelpText<"Text output format">;
-def gcc : Flag<["-","--"], "gcc", [Merge]>,
+def gcc : Flag<["--"], "gcc", [Merge]>,
           HelpText<"GCC encoding (only meaningful for -sample)">;
 def input_files
-    : JoinedOrSeparate<["-","--"], "input-files", [Merge]>,
+    : JoinedOrSeparate<["--"], "input-files", [Merge]>,
       HelpText<"Path to file containing newline-separated "
                "[<weight>,]<filename> entries">,
       MetaVarName<"<file>">;
 def : JoinedOrSeparate<["-"], "f", [Merge]>, Alias<input_files>,
      HelpText<"Alias for --input-files">;
-def dump_input_file_list : Flag<["-","--"], "dump-input-file-list", [Merge]>,
+def dump_input_file_list : Flag<["--"], "dump-input-file-list", [Merge]>,
                            HelpText<"Dump the list of input files and their "
-                                    "weights, then exit">,
-                           Flags<[HelpHidden]>;
+                                    "weights, then exit">;
+
 def remapping_file
-    : JoinedOrSeparate<["-","--"], "remapping-file", [Merge]>,
+    : JoinedOrSeparate<["--"], "remapping-file", [Merge]>,
       HelpText<"Symbol remapping file">, MetaVarName<"<file>">;
 def : JoinedOrSeparate<["-"], "r", [Merge]>, Alias<remapping_file>,
      HelpText<"Alias for --remapping-file">;
-def use_md5 : Flag<["-","--"], "use-md5", [Merge]>,
+def use_md5 : Flag<["--"], "use-md5", [Merge]>,
               HelpText<"Use MD5 to represent strings in the name table "
-                       "(only meaningful for -extbinary)">,
-              Flags<[HelpHidden]>;
+                       "(only meaningful for -extbinary)">;
+
 def compress_all_sections
-    : Flag<["-","--"], "compress-all-sections", [Merge]>,
-      HelpText<"Compress all sections when writing the profile (only "
-               "meaningful for -extbinary)">,
-      Flags<[HelpHidden]>;
-def compress_all_sections_EQ
-    : Joined<["-","--"], "compress-all-sections=", [Merge]>,
+    : Flag<["--"], "compress-all-sections", [Merge]>,
       HelpText<"Compress all sections when writing the profile (only "
-               "meaningful for -extbinary)">,
-      Flags<[HelpHidden]>;
+               "meaningful for -extbinary)">;
+
 def sample_merge_cold_context
-    : Flag<["-","--"], "sample-merge-cold-context", [Merge]>,
+    : Flag<["--"], "sample-merge-cold-context", [Merge]>,
       HelpText<"Merge context sample profiles whose count is below cold "
-               "threshold">,
-      Flags<[HelpHidden]>;
+               "threshold">;
+
 def sample_trim_cold_context
-    : Flag<["-","--"], "sample-trim-cold-context", [Merge]>,
+    : Flag<["--"], "sample-trim-cold-context", [Merge]>,
       HelpText<"Trim context sample profiles whose count is below cold "
-               "threshold">,
-      Flags<[HelpHidden]>;
+               "threshold">;
+
 def sample_frame_depth_for_cold_context
-    : JoinedOrSeparate<["-","--"], "sample-frame-depth-for-cold-context",
+    : JoinedOrSeparate<["--"], "sample-frame-depth-for-cold-context",
                        [Merge]>,
       HelpText<"Keep the last K frames while merging cold profile. 1 means "
                "the context-less base profile">,
-      Flags<[HelpHidden]>, MetaVarName<"<depth>">;
+      MetaVarName<"<depth>">;
 def output_size_limit
-    : JoinedOrSeparate<["-","--"], "output-size-limit", [Merge]>,
+    : JoinedOrSeparate<["--"], "output-size-limit", [Merge]>,
       HelpText<"Trim cold functions until profile size is below specified "
                "limit in bytes">,
-      Flags<[HelpHidden]>, MetaVarName<"<bytes>">;
+      MetaVarName<"<bytes>">;
 def gen_partial_profile
-    : Flag<["-","--"], "gen-partial-profile", [Merge]>,
-      HelpText<"Generate a partial profile (only meaningful for -extbinary)">,
-      Flags<[HelpHidden]>;
-def split_layout : Flag<["-","--"], "split-layout", [Merge]>,
+    : Flag<["--"], "gen-partial-profile", [Merge]>,
+      HelpText<"Generate a partial profile (only meaningful for -extbinary)">;
+
+def split_layout : Flag<["--"], "split-layout", [Merge]>,
                    HelpText<"Split the profile into sections with and without "
                             "inlined functions (only meaningful for "
-                            "-extbinary)">,
-                   Flags<[HelpHidden]>;
+                            "-extbinary)">;
+
 def supplement_instr_with_sample
-    : JoinedOrSeparate<["-","--"], "supplement-instr-with-sample", [Merge]>,
+    : JoinedOrSeparate<["--"], "supplement-instr-with-sample", [Merge]>,
       HelpText<"Supplement an instr profile with a sample profile. Output "
                "will be in instr format.">,
-      Flags<[HelpHidden]>, MetaVarName<"<sample-profile>">;
+      MetaVarName<"<sample-profile>">;
 def zero_counter_threshold
-    : JoinedOrSeparate<["-","--"], "zero-counter-threshold", [Merge]>,
+    : JoinedOrSeparate<["--"], "zero-counter-threshold", [Merge]>,
       HelpText<"Ratio of zero counters required to drop a function when "
                "supplementing instr profiles">,
-      Flags<[HelpHidden]>, MetaVarName<"<ratio>">;
+      MetaVarName<"<ratio>">;
 def suppl_min_size_threshold
-    : JoinedOrSeparate<["-","--"], "suppl-min-size-threshold", [Merge]>,
+    : JoinedOrSeparate<["--"], "suppl-min-size-threshold", [Merge]>,
       HelpText<"Assume functions smaller than this threshold can be inlined "
                "and will not be adjusted based on sample profile.">,
-      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+      MetaVarName<"<n>">;
 def instr_prof_cold_threshold
-    : JoinedOrSeparate<["-","--"], "instr-prof-cold-threshold", [Merge]>,
+    : JoinedOrSeparate<["--"], "instr-prof-cold-threshold", [Merge]>,
       HelpText<"User specified cold threshold for instr profile to override "
                "the cold threshold from profile summary.">,
-      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+      MetaVarName<"<n>">;
 def temporal_profile_trace_reservoir_size
-    : JoinedOrSeparate<["-","--"], "temporal-profile-trace-reservoir-size",
+    : JoinedOrSeparate<["--"], "temporal-profile-trace-reservoir-size",
                        [Merge]>,
       HelpText<"Maximum number of stored temporal profile traces (default: "
                "100)">,
       MetaVarName<"<n>">;
 def temporal_profile_max_trace_length
-    : JoinedOrSeparate<["-","--"], "temporal-profile-max-trace-length",
+    : JoinedOrSeparate<["--"], "temporal-profile-max-trace-length",
                        [Merge]>,
       HelpText<"Maximum length of a single temporal profile trace "
                "(default: 10000)">,
       MetaVarName<"<n>">;
-def no_function : JoinedOrSeparate<["-","--"], "no-function", [Merge]>,
+def no_function : JoinedOrSeparate<["--"], "no-function", [Merge]>,
                   HelpText<"Exclude functions matching the filter from the "
                            "output.">,
                   MetaVarName<"<regex>">;
 def failure_mode
-    : JoinedOrSeparate<["-","--"], "failure-mode", [Merge]>,
+    : JoinedOrSeparate<["--"], "failure-mode", [Merge]>,
       HelpText<"Failure mode: warn, any, or all">,
       MetaVarName<"<mode>">;
 def sparse
-    : Flag<["-","--"], "sparse", [Merge]>,
+    : Flag<["--"], "sparse", [Merge]>,
       HelpText<"Generate a sparse profile (only meaningful for -instr)">;
-def sparse_EQ
-    : Joined<["-","--"], "sparse=", [Merge]>,
-      HelpText<"Generate a sparse profile (only meaningful for -instr)">,
-      Flags<[HelpHidden]>;
 
-def profile_isfs : Flag<["-","--"], "profile-isfs", [Show, Merge]>,
-                   HelpText<"Profile uses flow-sensitive discriminators">,
-                   Flags<[HelpHidden]>;
+def profile_isfs : Flag<["--"], "profile-isfs", [Show, Merge]>,
+                   HelpText<"Profile uses flow-sensitive discriminators">;
+
 
 def generate_merged_base_profiles
-    : JoinedOrSeparate<["-","--"], "generate-merged-base-profiles", [Merge]>,
+    : Flag<["--"], "generate-merged-base-profiles", [Merge]>,
       HelpText<"Generate merged base profiles when creating nested "
-               "context-sensitive profiles">,
-      Flags<[HelpHidden]>;
+               "context-sensitive profiles">;
+
 
 def profile_symbol_list_cutoff
-    : JoinedOrSeparate<["-","--"], "profile-symbol-list-cutoff", [Merge]>,
-      HelpText<"Maximum number of symbols to keep in the profile symbol list">,
-      Flags<[HelpHidden]>;
+    : JoinedOrSeparate<["--"], "profile-symbol-list-cutoff", [Merge]>,
+      HelpText<"Maximum number of symbols to keep in the profile symbol list">;
+
 def profile_summary_cutoff_hot
-    : JoinedOrSeparate<["-","--"], "profile-summary-cutoff-hot",
+    : JoinedOrSeparate<["--"], "profile-summary-cutoff-hot",
                        [Show, Merge]>,
-      HelpText<"Percentile (times 10000) for determining hot threshold">,
-      Flags<[HelpHidden]>;
+      HelpText<"Percentile (times 10000) for determining hot threshold">;
+
 def profile_summary_cutoff_cold
-    : JoinedOrSeparate<["-","--"], "profile-summary-cutoff-cold",
+    : JoinedOrSeparate<["--"], "profile-summary-cutoff-cold",
                        [Show, Merge]>,
-      HelpText<"Percentile (times 10000) for determining cold threshold">,
-      Flags<[HelpHidden]>;
+      HelpText<"Percentile (times 10000) for determining cold threshold">;
+
 def profile_summary_hot_count
-    : JoinedOrSeparate<["-","--"], "profile-summary-hot-count",
+    : JoinedOrSeparate<["--"], "profile-summary-hot-count",
                        [Show, Merge]>,
-      HelpText<"Override hot count derived from summary cutoffs">,
-      Flags<[HelpHidden]>;
+      HelpText<"Override hot count derived from summary cutoffs">;
+
 def profile_summary_cold_count
-    : JoinedOrSeparate<["-","--"], "profile-summary-cold-count",
+    : JoinedOrSeparate<["--"], "profile-summary-cold-count",
                        [Show, Merge]>,
-      HelpText<"Override cold count derived from summary cutoffs">,
-      Flags<[HelpHidden]>;
+      HelpText<"Override cold count derived from summary cutoffs">;
+
 def profile_summary_contextless
-    : JoinedOrSeparate<["-","--"], "profile-summary-contextless",
+    : JoinedOrSeparate<["--"], "profile-summary-contextless",
                        [Show, Merge]>,
-      HelpText<"Merge context profiles before calculating summary thresholds">,
-      Flags<[HelpHidden]>;
+      HelpText<"Merge context profiles before calculating summary thresholds">;
+
 def profile_summary_huge_working_set_size_threshold
-    : JoinedOrSeparate<["-","--"],
+    : JoinedOrSeparate<["--"],
                        "profile-summary-huge-working-set-size-threshold",
                        [Show, Merge]>,
-      HelpText<"Threshold for huge working set size used in profile summary">,
-      Flags<[HelpHidden]>;
+      HelpText<"Threshold for huge working set size used in profile summary">;
+
 def profile_summary_large_working_set_size_threshold
-    : JoinedOrSeparate<["-","--"],
+    : JoinedOrSeparate<["--"],
                        "profile-summary-large-working-set-size-threshold",
                        [Show, Merge]>,
-      HelpText<"Threshold for large working set size used in profile summary">,
-      Flags<[HelpHidden]>;
-def num_threads : JoinedOrSeparate<["-","--"], "num-threads", [Merge]>,
+      HelpText<"Threshold for large working set size used in profile summary">;
+
+def num_threads : JoinedOrSeparate<["--"], "num-threads", [Merge]>,
                   HelpText<"Number of merge threads to use (default: autodetect)">,
                   MetaVarName<"<n>">;
 def : JoinedOrSeparate<["-"], "j", [Merge]>, Alias<num_threads>,
      HelpText<"Alias for --num-threads">;
 def prof_sym_list
-    : JoinedOrSeparate<["-","--"], "prof-sym-list", [Merge]>,
+    : JoinedOrSeparate<["--"], "prof-sym-list", [Merge]>,
       HelpText<"Path to file containing the list of function symbols used to "
                "populate profile symbol list">,
       MetaVarName<"<file>">;
 def convert_sample_profile_layout
-    : JoinedOrSeparate<["-","--"], "convert-sample-profile-layout", [Merge]>,
+    : JoinedOrSeparate<["--"], "convert-sample-profile-layout", [Merge]>,
       HelpText<"Convert the generated profile to a new layout: nest or flat">,
       MetaVarName<"<layout>">;
 def drop_profile_symbol_list
-    : Flag<["-","--"], "drop-profile-symbol-list", [Merge]>,
+    : Flag<["--"], "drop-profile-symbol-list", [Merge]>,
       HelpText<"Drop the profile symbol list when merging AutoFDO profiles "
-               "(only meaningful for -sample)">,
-      Flags<[HelpHidden]>;
+               "(only meaningful for -sample)">;
+
 def keep_vtable_symbols
-    : Flag<["-","--"], "keep-vtable-symbols", [Merge]>,
-      HelpText<"Keep the vtable symbols in indexed profiles">,
-      Flags<[HelpHidden]>;
+    : Flag<["--"], "keep-vtable-symbols", [Merge]>,
+      HelpText<"Keep the vtable symbols in indexed profiles">;
+
 def write_prev_version
-    : Flag<["-","--"], "write-prev-version", [Merge]>,
+    : Flag<["--"], "write-prev-version", [Merge]>,
       HelpText<"Write the previous version of indexed format for forward "
-               "compatibility.">,
-      Flags<[HelpHidden]>;
+               "compatibility.">;
+
 def memprof_version
-    : JoinedOrSeparate<["-","--"], "memprof-version", [Merge]>,
+    : JoinedOrSeparate<["--"], "memprof-version", [Merge]>,
       HelpText<"Specify the version of the memprof format to use (2, 3, or 4)">,
-      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+      MetaVarName<"<n>">;
 def memprof_full_schema
-    : Flag<["-","--"], "memprof-full-schema", [Merge]>,
-      HelpText<"Use the full schema for serialization">,
-      Flags<[HelpHidden]>;
+    : Flag<["--"], "memprof-full-schema", [Merge]>,
+      HelpText<"Use the full schema for serialization">;
+
 def memprof_random_hotness
-    : Flag<["-","--"], "memprof-random-hotness", [Merge]>,
-      HelpText<"Generate random hotness values">,
-      Flags<[HelpHidden]>;
+    : Flag<["--"], "memprof-random-hotness", [Merge]>,
+      HelpText<"Generate random hotness values">;
+
 def memprof_random_hotness_seed
-    : JoinedOrSeparate<["-","--"], "memprof-random-hotness-seed", [Merge]>,
+    : JoinedOrSeparate<["--"], "memprof-random-hotness-seed", [Merge]>,
       HelpText<"Random hotness seed to use (0 to generate new seed)">,
-      Flags<[HelpHidden]>, MetaVarName<"<n>">;
+      MetaVarName<"<n>">;
 
 def similarity_cutoff
-    : JoinedOrSeparate<["-","--"], "similarity-cutoff", [Overlap]>,
+    : JoinedOrSeparate<["--"], "similarity-cutoff", [Overlap]>,
       HelpText<"List overlapped functions with similarities below the cutoff "
                "(percentage times 10000).">,
       MetaVarName<"<n>">;
-def cs : Flag<["-","--"], "cs", [Overlap]>,
+def cs : Flag<["--"], "cs", [Overlap]>,
          HelpText<"For context sensitive PGO counts. Does not work with "
                   "CSSPGO.">;
 def value_cutoff
-    : JoinedOrSeparate<["-","--"], "value-cutoff", [Show, Overlap]>,
+    : JoinedOrSeparate<["--"], "value-cutoff", [Show, Overlap]>,
       HelpText<"Cutoff value used for filtering. Meaning depends on subcommand">,
       MetaVarName<"<n>">;
 
-def counts : Flag<["-","--"], "counts", [Show]>,
+def counts : Flag<["--"], "counts", [Show]>,
              HelpText<"Show counter values for shown functions">;
 def show_format
-    : JoinedOrSeparate<["-","--"], "show-format", [Show]>,
+    : JoinedOrSeparate<["--"], "show-format", [Show]>,
       HelpText<"Emit output in the selected format: text, json, or yaml">,
       MetaVarName<"<format>">;
-def json : Flag<["-","--"], "json", [Show]>,
+def json : Flag<["--"], "json", [Show]>,
            HelpText<"Show sample profile data in JSON format "
                     "(deprecated, use --show-format=json)">;
-def ic_targets : Flag<["-","--"], "ic-targets", [Show]>,
+def ic_targets : Flag<["--"], "ic-targets", [Show]>,
                  HelpText<"Show indirect call site target values">;
-def show_vtables : Flag<["-","--"], "show-vtables", [Show]>,
+def show_vtables : Flag<["--"], "show-vtables", [Show]>,
                    HelpText<"Show vtable names for shown functions">;
 def extbinary_write_vtable_type_prof
-    : Flag<["-","--"], "extbinary-write-vtable-type-prof", [Merge]>,
-      HelpText<"Include vtable type profile data in ext-binary sample profile">,
-      Flags<[HelpHidden]>;
-def memop_sizes : Flag<["-","--"], "memop-sizes", [Show]>,
+    : Flag<["--"], "extbinary-write-vtable-type-prof", [Merge]>,
+      HelpText<"Include vtable type profile data in ext-binary sample profile">;
+
+def memop_sizes : Flag<["--"], "memop-sizes", [Show]>,
                   HelpText<"Show profiled sizes of memory intrinsic calls">;
-def detailed_summary : Flag<["-","--"], "detailed-summary", [Show]>,
+def detailed_summary : Flag<["--"], "detailed-summary", [Show]>,
                        HelpText<"Show detailed profile summary">;
 def detailed_summary_cutoffs
-    : CommaJoined<["-","--"], "detailed-summary-cutoffs", [Show]>,
+    : JoinedOrSeparate<["--"], "detailed-summary-cutoffs", [Show]>,
       HelpText<"Cutoff percentages (times 10000) for generating detailed "
                "summary">,
       MetaVarName<"<list>">;
-def hot_func_list : Flag<["-","--"], "hot-func-list", [Show]>,
+def hot_func_list : Flag<["--"], "hot-func-list", [Show]>,
                     HelpText<"Show profile summary of a list of hot functions">;
-def all_functions : Flag<["-","--"], "all-functions", [Show]>,
+def all_functions : Flag<["--"], "all-functions", [Show]>,
                     HelpText<"Details for each and every function">;
-def showcs : Flag<["-","--"], "showcs", [Show]>,
+def showcs : Flag<["--"], "showcs", [Show]>,
              HelpText<"Show context sensitive counts">;
-def topn : JoinedOrSeparate<["-","--"], "topn", [Show]>,
+def topn : JoinedOrSeparate<["--"], "topn", [Show]>,
            HelpText<"Show the list of functions with the largest internal counts">,
            MetaVarName<"<n>">;
 def list_below_cutoff
-    : Flag<["-","--"], "list-below-cutoff", [Show]>,
+    : Flag<["--"], "list-below-cutoff", [Show]>,
       HelpText<"Only output names of functions whose max count values are "
                "below the cutoff value">;
 def show_prof_sym_list
-    : Flag<["-","--"], "show-prof-sym-list", [Show]>,
+    : Flag<["--"], "show-prof-sym-list", [Show]>,
       HelpText<"Show profile symbol list if it exists in the profile.">;
 def show_sec_info_only
-    : Flag<["-","--"], "show-sec-info-only", [Show]>,
+    : Flag<["--"], "show-sec-info-only", [Show]>,
       HelpText<"Show the information of each section in the sample profile "
                "(extbinary sample profiles only)">;
-def binary_ids : Flag<["-","--"], "binary-ids", [Show]>,
+def binary_ids : Flag<["--"], "binary-ids", [Show]>,
                  HelpText<"Show binary ids in the profile.">;
 def temporal_profile_traces
-    : Flag<["-","--"], "temporal-profile-traces", [Show]>,
+    : Flag<["--"], "temporal-profile-traces", [Show]>,
       HelpText<"Show temporal profile traces in the profile.">;
-def covered : Flag<["-","--"], "covered", [Show]>,
+def covered : Flag<["--"], "covered", [Show]>,
               HelpText<"Show only the functions that have been executed.">;
-def profile_version : Flag<["-","--"], "profile-version", [Show]>,
+def profile_version : Flag<["--"], "profile-version", [Show]>,
                       HelpText<"Show profile version.">;
 
 def num_test_traces
-    : JoinedOrSeparate<["-","--"], "num-test-traces", [Order]>,
+    : JoinedOrSeparate<["--"], "num-test-traces", [Order]>,
       HelpText<"Keep aside the last <num-test-traces> traces when computing "
                "function order to evaluate that order">,
       MetaVarName<"<n>">;
 
 def fs_discriminator_pass
-    : JoinedOrSeparate<["-","--"], "fs-discriminator-pass",
+    : JoinedOrSeparate<["--"], "fs-discriminator-pass",
                        [Show, Overlap, Merge]>,
       HelpText<"Zero out the discriminator bits for the FS discriminator "
                "pass beyond this value.">,
-      Flags<[HelpHidden]>, MetaVarName<"<pass>">;
+      MetaVarName<"<pass>">;
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 5215578eede46..28439bfe3a9e6 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -609,11 +609,13 @@ getFuncName(const StringMap<InstrProfWriter::ProfilingData>::value_type &Val) {
   return Val.first();
 }
 
-static std::string getFuncName(const SampleProfileMap::value_type &Val) {
+static std::string
+getFuncName(const SampleProfileMap::value_type &Val) {
   return Val.second.getContext().toString();
 }
 
-template <typename T> static void filterFunctions(T &ProfileMap) {
+template <typename T>
+static void filterFunctions(T &ProfileMap) {
   bool hasFilter = !FuncNameFilter.empty();
   bool hasNegativeFilter = !FuncNameNegativeFilter.empty();
   if (!hasFilter && !hasNegativeFilter)
@@ -1201,8 +1203,8 @@ remapSamples(const sampleprof::FunctionSamples &Samples,
                           BodySample.second.getSamples());
     for (const auto &Target : BodySample.second.getCallTargets()) {
       Result.addCalledTargetSamples(BodySample.first.LineOffset,
-                                    MaskedDiscriminator, Remapper(Target.first),
-                                    Target.second);
+                                    MaskedDiscriminator,
+                                    Remapper(Target.first), Target.second);
     }
   }
   for (const auto &CallsiteSamples : Samples.getCallsiteSamples()) {
@@ -1219,8 +1221,12 @@ remapSamples(const sampleprof::FunctionSamples &Samples,
 }
 
 static sampleprof::SampleProfileFormat FormatMap[] = {
-    sampleprof::SPF_None,       sampleprof::SPF_Text, sampleprof::SPF_None,
-    sampleprof::SPF_Ext_Binary, sampleprof::SPF_GCC,  sampleprof::SPF_Binary};
+    sampleprof::SPF_None,
+    sampleprof::SPF_Text,
+    sampleprof::SPF_None,
+    sampleprof::SPF_Ext_Binary,
+    sampleprof::SPF_GCC,
+    sampleprof::SPF_Binary};
 
 static std::unique_ptr<MemoryBuffer>
 getInputFileBuf(const StringRef &InputFile) {
@@ -1479,7 +1485,7 @@ static int merge_main(StringRef ProgName) {
   parseInputFilenamesFile(Buffer.get(), WeightedInputs);
 
   if (WeightedInputs.empty())
-    exitWithError("no input files specified. See " + ProgName + " merge -help");
+    exitWithError("no input files specified. See " + ProgName + " merge --help");
 
   if (DumpInputFileList) {
     for (auto &WF : WeightedInputs)
@@ -3068,8 +3074,9 @@ static int showDebugInfoCorrelation(const std::string &Filename,
 
 static int show_main(StringRef ProgName) {
   if (Filename.empty() && DebugInfoFilename.empty())
-    exitWithError("the positional argument '<profdata-file>' is required "
-                  "unless '--debug-info' is provided");
+    exitWithError(
+        "the positional argument '<profdata-file>' is required unless "
+        "'--debug-info' is provided");
 
   if (Filename == OutputFilename) {
     errs() << ProgName
@@ -3086,8 +3093,7 @@ static int show_main(StringRef ProgName) {
     exitWithErrorCode(EC, OutputFilename);
 
   if (ShowAllFunctions && !FuncNameFilter.empty())
-    WithColor::warning()
-        << "-function argument ignored: showing all functions\n";
+    WithColor::warning() << "-function argument ignored: showing all functions\n";
 
   if (!DebugInfoFilename.empty())
     return showDebugInfoCorrelation(DebugInfoFilename, SFormat, OS);
@@ -3168,56 +3174,11 @@ static void reportCmdLineError(const Twine &Message) {
   WithColor::error(errs(), ProgramName) << Message << "\n";
 }
 
-static StringRef getOptionValue(const opt::Arg *A) {
-  if (A->getNumValues() == 0)
-    return StringRef();
-  StringRef V = A->getValue();
-  V.consume_front("=");
-  return V;
-}
-
-static std::string getLastArgValueClean(const opt::InputArgList &Args,
-                                        unsigned OptionID,
-                                        StringRef Default = "") {
-  if (const opt::Arg *A = Args.getLastArg(OptionID))
-    return getOptionValue(A).str();
-  return Default.str();
-}
-
-static std::vector<std::string>
-getAllArgValuesClean(const opt::InputArgList &Args, unsigned OptionID) {
-  std::vector<std::string> Values;
-  for (const opt::Arg *A : Args.filtered(OptionID))
-    Values.push_back(getOptionValue(A).str());
-  return Values;
-}
-
-static bool parseBooleanOption(const opt::Arg *A, bool &Value) {
-  if (!A)
-    return true;
-  StringRef V = getOptionValue(A);
-  if (V.empty()) {
-    Value = true;
-    return true;
-  }
-  if (V.equals_insensitive("true") || V == "1") {
-    Value = true;
-    return true;
-  }
-  if (V.equals_insensitive("false") || V == "0") {
-    Value = false;
-    return true;
-  }
-  reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
-                     A->getSpelling() + "'");
-  return false;
-}
-
 template <typename T>
 static bool parseNumericOption(const opt::Arg *A, T &Value) {
   if (!A)
     return true;
-  StringRef V = getOptionValue(A);
+  StringRef V = A->getValue();
   T Parsed{};
   if (!llvm::to_integer(V, Parsed, 0)) {
     if (!std::numeric_limits<T>::is_signed && V == "-1") {
@@ -3232,19 +3193,13 @@ static bool parseNumericOption(const opt::Arg *A, T &Value) {
   return true;
 }
 
-static bool applyLibraryOptionsWithCL(const opt::InputArgList &Args) {
+static bool applyLibraryOptions(const opt::InputArgList &Args) {
   SmallVector<std::string, 16> CLStrings;
   CLStrings.push_back(ProgramName);
 
-  auto AddBool = [&](unsigned OptID, StringRef Spelling) -> bool {
-    if (const opt::Arg *A = Args.getLastArg(OptID)) {
-      bool Value = true;
-      if (!parseBooleanOption(A, Value))
-        return false;
-      CLStrings.push_back(
-          (Spelling + Twine("=") + (Value ? "true" : "false")).str());
-    }
-    return true;
+  auto AddFlag = [&](unsigned OptID, StringRef Spelling) {
+    if (Args.hasArg(OptID))
+      CLStrings.push_back(Spelling.str());
   };
   auto AddUInt = [&](unsigned OptID, StringRef Spelling) -> bool {
     if (const opt::Arg *A = Args.getLastArg(OptID)) {
@@ -3265,20 +3220,14 @@ static bool applyLibraryOptionsWithCL(const opt::InputArgList &Args) {
     return true;
   };
 
-  if (!AddBool(OPT_profile_isfs, "--profile-isfs"))
-    return false;
-  if (!AddBool(OPT_generate_merged_base_profiles,
-               "--generate-merged-base-profiles"))
-    return false;
+  AddFlag(OPT_profile_isfs, "--profile-isfs");
+  AddFlag(OPT_generate_merged_base_profiles, "--generate-merged-base-profiles");
   if (!AddUInt(OPT_profile_symbol_list_cutoff, "--profile-symbol-list-cutoff"))
     return false;
-  if (!AddBool(OPT_extbinary_write_vtable_type_prof,
-               "--extbinary-write-vtable-type-prof"))
-    return false;
+  AddFlag(OPT_extbinary_write_vtable_type_prof,
+          "--extbinary-write-vtable-type-prof");
 
-  if (!AddBool(OPT_profile_summary_contextless,
-               "--profile-summary-contextless"))
-    return false;
+  AddFlag(OPT_profile_summary_contextless, "--profile-summary-contextless");
   if (!AddInt(OPT_profile_summary_cutoff_hot, "--profile-summary-cutoff-hot"))
     return false;
   if (!AddInt(OPT_profile_summary_cutoff_cold, "--profile-summary-cutoff-cold"))
@@ -3311,7 +3260,7 @@ static bool applyLibraryOptionsWithCL(const opt::InputArgList &Args) {
 static bool parseFloatOption(const opt::Arg *A, float &Value) {
   if (!A)
     return true;
-  StringRef V = getOptionValue(A);
+  StringRef V = A->getValue();
   double Parsed;
   if (V.getAsDouble(Parsed)) {
     reportCmdLineError(Twine("invalid argument '") + V + "' for option '" +
@@ -3327,17 +3276,9 @@ static bool parseCutoffValues(const opt::InputArgList &Args,
   Cutoffs.clear();
   for (const opt::Arg *A : Args.filtered(OPT_detailed_summary_cutoffs)) {
     SmallVector<StringRef, 4> Parts;
-    if (A->getNumValues() <= 1) {
-      getOptionValue(A).split(Parts, ',', /*MaxSplit=*/-1,
-                              /*KeepEmpty=*/false);
-    } else {
-      for (unsigned I = 0, E = A->getNumValues(); I != E; ++I) {
-        StringRef Part = A->getValue(I);
-        if (!Part.empty() && Part.front() == '=')
-          Part = Part.drop_front();
-        Parts.push_back(Part);
-      }
-    }
+    StringRef(A->getValue())
+        .split(Parts, ',', /*MaxSplit=*/-1,
+               /*KeepEmpty=*/false);
     for (StringRef Part : Parts) {
       uint32_t Parsed;
       if (!llvm::to_integer(Part, Parsed, 0)) {
@@ -3356,7 +3297,7 @@ static bool parseFSDiscriminatorPassArg(const opt::InputArgList &Args) {
   if (!A)
     return true;
 
-  StringRef Value = getOptionValue(A);
+  StringRef Value = A->getValue();
   auto Parsed = StringSwitch<std::optional<FSDiscriminatorPass>>(Value)
                     .Case("Base", FSDiscriminatorPass::Base)
                     .Case("base", FSDiscriminatorPass::Base)
@@ -3386,6 +3327,9 @@ static bool validateSubcommandOptions(const opt::InputArgList &Args,
     if (A->getOption().matches(OPT_UNKNOWN) ||
         A->getOption().matches(OPT_INPUT))
       continue;
+    // Options without an explicit subcommand are available everywhere.
+    if (A->getOption().matches(OPT_help) || A->getOption().matches(OPT_version))
+      continue;
     if (A->getOption().isRegisteredSC(Subcommand))
       continue;
     reportCmdLineError(Twine("unknown command line argument '") +
@@ -3399,24 +3343,24 @@ static bool validateSubcommandOptions(const opt::InputArgList &Args,
 
 static bool parseMergeOptions(const opt::InputArgList &Args,
                               ArrayRef<StringRef> Positionals) {
-  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
   if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
     ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
-  if (!applyLibraryOptionsWithCL(Args))
+  if (!applyLibraryOptions(Args))
     return false;
 
   if (!parseNumericOption(
           Args.getLastArg(OPT_max_debug_info_correlation_warnings),
           MaxDbgCorrelationWarnings))
     return false;
-  ProfiledBinary = getLastArgValueClean(Args, OPT_profiled_binary);
-  DebugInfoFilename = getLastArgValueClean(Args, OPT_debug_info);
-  BinaryFilename = getLastArgValueClean(Args, OPT_binary_file);
-  DebugFileDirectory = getAllArgValuesClean(Args, OPT_debug_file_directory);
+  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
+  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
+  BinaryFilename = Args.getLastArgValue(OPT_binary_file).str();
+  DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory);
   DebugInfod = Args.hasArg(OPT_debuginfod);
 
   if (const opt::Arg *A = Args.getLastArg(OPT_correlate)) {
-    StringRef V = getOptionValue(A);
+    StringRef V = A->getValue();
     auto Parsed = StringSwitch<std::optional<ProfCorrelatorKind>>(V)
                       .Case("", InstrProfCorrelator::NONE)
                       .Case("debug-info", InstrProfCorrelator::DEBUG_INFO)
@@ -3430,12 +3374,12 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
     BIDFetcherProfileCorrelate = *Parsed;
   }
 
-  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
   InputFilenames.clear();
   InputFilenames.reserve(Positionals.size());
   for (StringRef Pos : Positionals)
     InputFilenames.emplace_back(Pos.str());
-  WeightedInputFilenames = getAllArgValuesClean(Args, OPT_weighted_input);
+  WeightedInputFilenames = Args.getAllArgValues(OPT_weighted_input);
 
   OutputFormat = PF_Ext_Binary;
   if (const opt::Arg *Fmt =
@@ -3450,15 +3394,11 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
       OutputFormat = PF_Ext_Binary;
   }
 
-  InputFilenamesFile = getLastArgValueClean(Args, OPT_input_files);
+  InputFilenamesFile = Args.getLastArgValue(OPT_input_files).str();
   DumpInputFileList = Args.hasArg(OPT_dump_input_file_list);
-  RemappingFile = getLastArgValueClean(Args, OPT_remapping_file);
+  RemappingFile = Args.getLastArgValue(OPT_remapping_file).str();
   UseMD5 = Args.hasArg(OPT_use_md5);
-  const opt::Arg *CompressArg =
-      Args.getLastArg(OPT_compress_all_sections, OPT_compress_all_sections_EQ);
-  CompressAllSections = CompressArg != nullptr;
-  if (!parseBooleanOption(CompressArg, CompressAllSections))
-    return false;
+  CompressAllSections = Args.hasArg(OPT_compress_all_sections);
   SampleMergeColdContext = Args.hasArg(OPT_sample_merge_cold_context);
   SampleTrimColdContext = Args.hasArg(OPT_sample_trim_cold_context);
   if (!parseNumericOption(
@@ -3471,7 +3411,7 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
   GenPartialProfile = Args.hasArg(OPT_gen_partial_profile);
   SplitLayout = Args.hasArg(OPT_split_layout);
   SupplInstrWithSample =
-      getLastArgValueClean(Args, OPT_supplement_instr_with_sample);
+      Args.getLastArgValue(OPT_supplement_instr_with_sample).str();
   if (!parseFloatOption(Args.getLastArg(OPT_zero_counter_threshold),
                         ZeroCounterThreshold))
     return false;
@@ -3489,12 +3429,9 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
           Args.getLastArg(OPT_temporal_profile_max_trace_length),
           TemporalProfMaxTraceLength))
     return false;
-  FuncNameNegativeFilter = getLastArgValueClean(Args, OPT_no_function);
+  FuncNameNegativeFilter = Args.getLastArgValue(OPT_no_function).str();
 
-  StringRef FailureModeValue =
-      Args.getLastArg(OPT_failure_mode)
-          ? getOptionValue(Args.getLastArg(OPT_failure_mode))
-          : StringRef("any");
+  StringRef FailureModeValue = Args.getLastArgValue(OPT_failure_mode, "any");
   auto ParsedFailMode =
       StringSwitch<std::optional<FailureMode>>(FailureModeValue)
           .Case("warn", warnOnly)
@@ -3508,16 +3445,13 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
   }
   FailMode = *ParsedFailMode;
 
-  const opt::Arg *SparseArg = Args.getLastArg(OPT_sparse, OPT_sparse_EQ);
-  OutputSparse = SparseArg != nullptr;
-  if (!parseBooleanOption(SparseArg, OutputSparse))
-    return false;
+  OutputSparse = Args.hasArg(OPT_sparse);
   if (!parseNumericOption(Args.getLastArg(OPT_num_threads), NumThreads))
     return false;
-  ProfileSymbolListFile = getLastArgValueClean(Args, OPT_prof_sym_list);
+  ProfileSymbolListFile = Args.getLastArgValue(OPT_prof_sym_list).str();
 
   if (const opt::Arg *A = Args.getLastArg(OPT_convert_sample_profile_layout)) {
-    StringRef Layout = getOptionValue(A);
+    StringRef Layout = A->getValue();
     auto ParsedLayout = StringSwitch<std::optional<SampleProfileLayout>>(Layout)
                             .Case("nest", SPL_Nest)
                             .Case("flat", SPL_Flat)
@@ -3535,7 +3469,7 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
   DoWritePrevVersion = Args.hasArg(OPT_write_prev_version);
 
   if (const opt::Arg *A = Args.getLastArg(OPT_memprof_version)) {
-    StringRef Version = getOptionValue(A);
+    StringRef Version = A->getValue();
     auto ParsedVersion =
         StringSwitch<std::optional<memprof::IndexedVersion>>(Version)
             .Case("2", memprof::Version2)
@@ -3564,7 +3498,7 @@ static bool parseMergeOptions(const opt::InputArgList &Args,
 
 static bool parseShowOptions(const opt::InputArgList &Args,
                              ArrayRef<StringRef> Positionals) {
-  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
   if (!Positionals.empty()) {
     Filename = Positionals.front().str();
     if (Positionals.size() > 1) {
@@ -3572,20 +3506,31 @@ static bool parseShowOptions(const opt::InputArgList &Args,
       return false;
     }
   }
+  if (Filename.empty() && DebugInfoFilename.empty()) {
+    reportCmdLineError(
+        "the positional argument '<profdata-file>' is required unless "
+        "'--debug-info' is provided");
+    return false;
+  }
+  if (!Filename.empty() && OutputFilename == Filename) {
+    reportCmdLineError("show: Input file name cannot be the same as the "
+                       "output file name!");
+    return false;
+  }
 
   if (!parseNumericOption(
           Args.getLastArg(OPT_max_debug_info_correlation_warnings),
           MaxDbgCorrelationWarnings))
     return false;
-  if (!applyLibraryOptionsWithCL(Args))
+  if (!applyLibraryOptions(Args))
     return false;
-  ProfiledBinary = getLastArgValueClean(Args, OPT_profiled_binary);
-  DebugInfoFilename = getLastArgValueClean(Args, OPT_debug_info);
-  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
+  ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str();
+  DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str();
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
 
   ShowCounts = Args.hasArg(OPT_counts);
   if (const opt::Arg *A = Args.getLastArg(OPT_show_format)) {
-    StringRef Value = getOptionValue(A);
+    StringRef Value = A->getValue();
     auto Parsed = StringSwitch<std::optional<ShowFormat>>(Value)
                       .Case("text", ShowFormat::Text)
                       .Case("json", ShowFormat::Json)
@@ -3638,7 +3583,7 @@ static bool parseShowOptions(const opt::InputArgList &Args,
 
 static bool parseOverlapOptions(const opt::InputArgList &Args,
                                 ArrayRef<StringRef> Positionals) {
-  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
   if (Positionals.size() != 2) {
     reportCmdLineError("overlap requires two positional profile filenames");
     return false;
@@ -3649,7 +3594,7 @@ static bool parseOverlapOptions(const opt::InputArgList &Args,
   if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr))
     ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr;
 
-  FuncNameFilter = getLastArgValueClean(Args, OPT_function);
+  FuncNameFilter = Args.getLastArgValue(OPT_function).str();
   if (!parseNumericOption(Args.getLastArg(OPT_similarity_cutoff),
                           SimilarityCutoff))
     return false;
@@ -3666,7 +3611,7 @@ static bool parseOverlapOptions(const opt::InputArgList &Args,
 
 static bool parseOrderOptions(const opt::InputArgList &Args,
                               ArrayRef<StringRef> Positionals) {
-  OutputFilename = getLastArgValueClean(Args, OPT_output, "-");
+  OutputFilename = Args.getLastArgValue(OPT_output, "-").str();
   if (!Positionals.empty()) {
     Filename = Positionals.front().str();
     if (Positionals.size() > 1) {
@@ -3685,53 +3630,13 @@ int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) {
 
   ProgramName = sys::path::stem(argv[0]).str();
 
-  ProfdataOptTable Tbl;
-  ArrayRef<opt::OptTable::SubCommand> KnownSubcommands = Tbl.getSubCommands();
-  auto IsKnownSubcommand = [&](StringRef Name) {
-    return llvm::any_of(
-        KnownSubcommands,
-        [&](const opt::OptTable::SubCommand &SC) { return Name == SC.Name; });
-  };
-  ArrayRef<const char *> RawArgs(argv + 1, argv + argc);
-  SmallVector<StringRef, 4> RawSubcommands;
-  for (const char *Arg : RawArgs) {
-    StringRef ArgRef(Arg);
-    if (!ArgRef.starts_with("-") && IsKnownSubcommand(ArgRef))
-      RawSubcommands.push_back(ArgRef);
-  }
-  auto HasFlag = [&](StringRef Flag) {
-    return llvm::is_contained(RawArgs, Flag);
-  };
-  auto HasAnySubcommand = [&]() { return !RawSubcommands.empty(); };
-
-  if (!HasAnySubcommand()) {
-    if (HasFlag("--help") || HasFlag("-help") || HasFlag("-h")) {
-      std::string Usage = ProgramName + " [subcommand] [options]";
-      Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
-                    /*ShowHidden=*/false, /*ShowAllAliases=*/false,
-                    Visibility(), /*Subcommand=*/{});
-      return 0;
-    }
-    if (HasFlag("--help-hidden")) {
-      std::string Usage = ProgramName + " [subcommand] [options]";
-      Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
-                    /*ShowHidden=*/true, /*ShowAllAliases=*/false, Visibility(),
-                    /*Subcommand=*/{});
-      return 0;
-    }
-    if (HasFlag("--version") || HasFlag("-version")) {
-      outs() << ProgramName << '\n';
-      cl::PrintVersionMessage();
-      return 0;
-    }
-  }
-
-  if (argc <= 1) {
+  if (argc == 1) {
     errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
            << " --help for usage.\n";
     return 1;
   }
 
+  ProfdataOptTable Tbl;
   bool HadParseError = false;
   opt::InputArgList Args =
       Tbl.parseArgs(argc - 1, argv + 1, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
@@ -3748,83 +3653,64 @@ int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) {
     WithColor::error(errs(), ProgramName) << "multiple subcommands specified:";
     for (StringRef SC : SubCommands)
       errs() << " '" << SC << "'";
-    errs() << ".\n";
+    errs() << "\n";
   };
   auto HandleOtherPositionals = [&](ArrayRef<StringRef> Positionals) {
     OtherPositionals.append(Positionals.begin(), Positionals.end());
   };
 
+  auto IsKnownSubcommand = [&](StringRef Name) {
+    return llvm::any_of(
+        Tbl.getSubCommands(),
+        [&](const opt::OptTable::SubCommand &SC) { return Name == SC.Name; });
+  };
+
+  StringRef RawFirstArg = argc > 1 ? StringRef(argv[1]) : StringRef();
+  StringRef RawSubcommand =
+      IsKnownSubcommand(RawFirstArg) ? RawFirstArg : StringRef();
+
   StringRef Subcommand = Args.getSubCommand(
       Tbl.getSubCommands(), HandleMultipleSubcommands, HandleOtherPositionals);
   if (HadSubcommandError)
     return 1;
 
-  if (Subcommand.empty() && RawSubcommands.size() > 1) {
-    HadSubcommandError = true;
-    HandleMultipleSubcommands(RawSubcommands);
-  }
-  if (HadSubcommandError)
-    return 1;
-
-  if (Subcommand.empty() && argc > 1 && IsKnownSubcommand(argv[1]))
-    Subcommand = argv[1];
   if (Subcommand.empty() && !OtherPositionals.empty() &&
       IsKnownSubcommand(OtherPositionals.front())) {
     Subcommand = OtherPositionals.front();
     OtherPositionals.erase(OtherPositionals.begin());
   }
-  if (Subcommand.empty() && RawSubcommands.size() == 1)
-    Subcommand = RawSubcommands.front();
-  if (!Subcommand.empty()) {
+  if (Subcommand.empty() && !RawSubcommand.empty()) {
+    Subcommand = RawSubcommand;
     auto It = llvm::find(OtherPositionals, Subcommand);
     if (It != OtherPositionals.end())
       OtherPositionals.erase(It);
   }
 
-  ArrayRef<StringRef> Positionals = OtherPositionals;
-
-  bool ShowHidden = Args.hasArg(OPT_help_hidden);
-  if (Args.hasArg(OPT_help) || ShowHidden) {
+  if (Args.hasArg(OPT_help)) {
     std::string Usage = ProgramName + " [subcommand] [options]";
     Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data",
-                  /*ShowHidden=*/ShowHidden, /*ShowAllAliases=*/false,
-                  Visibility(), Subcommand);
+                  /*ShowHidden=*/false, /*ShowAllAliases=*/false, Visibility(),
+                  Subcommand);
+    return 0;
+  }
+
+  if (Args.hasArg(OPT_version)) {
+    outs() << ProgramName << '\n';
+    cl::PrintVersionMessage();
     return 0;
   }
 
   if (Subcommand.empty()) {
-    if (Args.hasArg(OPT_version)) {
-      outs() << ProgramName << '\n';
-      cl::PrintVersionMessage();
-      return 0;
-    }
-    if (!OtherPositionals.empty()) {
-      WithColor::error(errs(), ProgramName) << "Unknown command";
-      if (OtherPositionals.size() != 1)
-        errs() << "s";
-      errs() << " ";
-      for (size_t I = 0; I < OtherPositionals.size(); ++I) {
-        if (I)
-          errs() << ", ";
-        errs() << "'" << OtherPositionals[I] << "'";
-      }
-      errs() << ". Run " << ProgramName << " --help for usage.\n";
-    } else {
-      errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
-             << " --help for usage.\n";
-    }
+    errs() << ProgramName << ": No subcommand specified! Run " << ProgramName
+           << " --help for usage.\n";
     return 1;
   }
 
+  ArrayRef<StringRef> Positionals = OtherPositionals;
+
   if (!validateSubcommandOptions(Args, Subcommand))
     return 1;
 
-  if (Args.hasArg(OPT_version)) {
-    outs() << ProgramName << '\n';
-    cl::PrintVersionMessage();
-    return 0;
-  }
-
   if (Subcommand == "merge") {
     if (!parseMergeOptions(Args, Positionals))
       return 1;



More information about the cfe-commits mailing list