aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
authorArchibald Elliott <archibald.elliott@arm.com>2022-12-13 22:02:58 +0000
committerArchibald Elliott <archibald.elliott@arm.com>2022-12-20 09:56:14 +0000
commit142aa1bdd1dd1db9a7fecf9d157228019c794c94 (patch)
treefe701b132a9055672d213ba2f12812792063a837 /llvm/tools/llvm-mca/llvm-mca.cpp
parentb76cc30e15855bf3ed094e680448e08e42e7d99d (diff)
downloadllvm-142aa1bdd1dd1db9a7fecf9d157228019c794c94.zip
llvm-142aa1bdd1dd1db9a7fecf9d157228019c794c94.tar.gz
llvm-142aa1bdd1dd1db9a7fecf9d157228019c794c94.tar.bz2
[Support] Move Target/CPU Printing out of CommandLine
This change is rather more invasive than intended. The main intention here is to make CommandLine.cpp not rely on llvm/Support/Host.h. Right now, this reliance is only in 3 superficial places: - Choosing how to expand response files (in two places) - Printing the default triple and current CPU in `--version` output. The built in version system has a method for adding "extra version printers", commonly used by several tools (such as llc) to report the registered targets in the built version of LLVM. It was reasonably easy to move the logic for printing the default triple and current CPU into a similar function, and register it with any relevant binaries. The incompatible change here is that now, even if LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO is defined, most binaries will no longer print out the default target triple and cpu when provided with `--version`, for instance llvm-as and llvm-dis. This breakage is intended, but the changes in this patch keep printing the default target and detected in `llc` and `opt` as these were remarked as important binaries in the LLVM install. The change to expanding response files may also be controversial, but I believe that these macros should correspond exactly to the host triple introspection used before. Differential Revision: https://reviews.llvm.org/D137837
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 2a27fea..73c3418 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -322,6 +322,9 @@ int main(int argc, char **argv) {
InitializeAllAsmParsers();
InitializeAllTargetMCAs();
+ // Register the Target and CPU printer for --version.
+ cl::AddExtraVersionPrinter(sys::printDefaultTargetAndDetectedCPU);
+
// Enable printing of available targets when flag --version is specified.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);