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