diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-04-11 18:12:00 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-04-11 18:12:00 +0000 |
commit | be0ad757ca983d9b275023777f6dea711ba9e11e (patch) | |
tree | 7eb7891cf761c5903bf0e20171d7c522559f7bfc /tools/llvm-lto2 | |
parent | 3a60ccfe457b5dbebdb1bc8a25c2d9ef1fbb547d (diff) |
llvm-lto2: Move the LTO::run() action behind a subcommand.
Move LTO::run() to a "run" subcommand so that we can introduce new subcommands
for testing different parts of the LTO implementation.
This doesn't use llvm::cl subcommands because it doesn't appear to be currently
possible to pass an argument not associated with a subcommand to a subcommand
(e.g. -lto-use-new-pm, -mcpu=yonah).
Differential Revision: https://reviews.llvm.org/D31410
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-lto2')
-rw-r--r-- | tools/llvm-lto2/llvm-lto2.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp index b5b29623ab5..faa658d93a3 100644 --- a/tools/llvm-lto2/llvm-lto2.cpp +++ b/tools/llvm-lto2/llvm-lto2.cpp @@ -126,12 +126,12 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) { return T(); } -int main(int argc, char **argv) { - InitializeAllTargets(); - InitializeAllTargetMCs(); - InitializeAllAsmPrinters(); - InitializeAllAsmParsers(); +static int usage() { + errs() << "Available subcommands: run\n"; + return 1; +} +static int run(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "Resolution-based LTO test harness"); // FIXME: Workaround PR30396 which means that a symbol can appear @@ -284,4 +284,25 @@ int main(int argc, char **argv) { Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache"); check(Lto.run(AddStream, Cache), "LTO::run failed"); + return 0; +} + +int main(int argc, char **argv) { + InitializeAllTargets(); + InitializeAllTargetMCs(); + InitializeAllAsmPrinters(); + InitializeAllAsmParsers(); + + // FIXME: This should use llvm::cl subcommands, but it isn't currently + // possible to pass an argument not associated with a subcommand to a + // subcommand (e.g. -lto-use-new-pm). + if (argc < 2) + return usage(); + + StringRef Subcommand = argv[1]; + // Ensure that argv[0] is correct after adjusting argv/argc. + argv[1] = argv[0]; + if (Subcommand == "run") + return run(argc - 1, argv + 1); + return usage(); } |