[Support] Move Target/CPU Printing out of CommandLine
authorArchibald Elliott <archibald.elliott@arm.com>
Tue, 13 Dec 2022 22:02:58 +0000 (22:02 +0000)
committerArchibald Elliott <archibald.elliott@arm.com>
Tue, 20 Dec 2022 09:56:14 +0000 (09:56 +0000)
commit142aa1bdd1dd1db9a7fecf9d157228019c794c94
treefe701b132a9055672d213ba2f12812792063a837
parentb76cc30e15855bf3ed094e680448e08e42e7d99d
[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
llvm/include/llvm/Support/Host.h
llvm/lib/MC/TargetRegistry.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/Host.cpp
llvm/test/tools/llvm-libtool-darwin/ignored-options.test
llvm/tools/llc/llc.cpp
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
llvm/tools/llvm-mca/llvm-mca.cpp
llvm/tools/opt/opt.cpp