Add usage blurb
[oota-llvm.git] / tools / bugpoint / bugpoint.cpp
1 //===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===//
2 //
3 // This program is an automated compiler debugger tool.  It is used to narrow
4 // down miscompilations and crash problems to a specific pass in the compiler,
5 // and the specific Module or Function input that is causing the problem.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "BugDriver.h"
10 #include "llvm/Support/PassNameParser.h"
11 #include "Support/CommandLine.h"
12 #include "Config/unistd.h"
13 #include <sys/resource.h>
14
15 static cl::list<std::string>
16 InputFilenames(cl::Positional, cl::OneOrMore,
17                cl::desc("<input llvm ll/bc files>"));
18
19 // The AnalysesList is automatically populated with registered Passes by the
20 // PassNameParser.
21 //
22 static cl::list<const PassInfo*, bool, PassNameParser>
23 PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
24
25 int main(int argc, char **argv) {
26   cl::ParseCommandLineOptions(argc, argv,
27                               " LLVM automatic testcase reducer. See\nhttp://"
28                               "llvm.cs.uiuc.edu/docs/CommandGuide/bugpoint.html"
29                               " for more information.\n");
30
31   BugDriver D(argv[0]);
32   if (D.addSources(InputFilenames)) return 1;
33   D.addPasses(PassList.begin(), PassList.end());
34
35   // Bugpoint has the ability of generating a plethora of core files, so to
36   // avoid filling up the disk, set the max core file size to 0.
37   struct rlimit rlim;
38   rlim.rlim_cur = rlim.rlim_max = 0;
39   int res = setrlimit(RLIMIT_CORE, &rlim);
40   if (res < 0) {
41     // setrlimit() may have failed, but we're not going to let that stop us
42     perror("setrlimit: RLIMIT_CORE");
43   }
44
45   return D.run();
46 }