summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-04-11 18:12:00 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-04-11 18:12:00 +0000
commit7faa60c406e501d4b78f1355a89de68023d78381 (patch)
tree161f4e5acb324920181eae00ce1ccadc6e9385e0 /llvm/tools
parent271b2245f40af1c363d10404d0c4d7c5e64d19c3 (diff)
downloadbcm5719-llvm-7faa60c406e501d4b78f1355a89de68023d78381.tar.gz
bcm5719-llvm-7faa60c406e501d4b78f1355a89de68023d78381.zip
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 llvm-svn: 299967
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index b5b29623ab5..faa658d93a3 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/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();
}
OpenPOWER on IntegriCloud