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