Chris Lattner | 9e97f4a | 2003-05-03 03:18:41 +0000 | [diff] [blame] | 1 | //===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===// |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 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" |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 10 | #include "llvm/Support/PassNameParser.h" |
Misha Brukman | 0c2305b | 2003-08-07 21:19:30 +0000 | [diff] [blame] | 11 | #include "Support/CommandLine.h" |
Misha Brukman | 46e18d4 | 2003-09-12 20:42:57 +0000 | [diff] [blame^] | 12 | #include "Config/unistd.h" |
| 13 | #include <sys/resource.h> |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 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> |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 23 | PassList(cl::desc("Passes available:"), cl::ZeroOrMore); |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 24 | |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 25 | int main(int argc, char **argv) { |
| 26 | cl::ParseCommandLineOptions(argc, argv); |
| 27 | |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 28 | BugDriver D(argv[0]); |
| 29 | if (D.addSources(InputFilenames)) return 1; |
| 30 | D.addPasses(PassList.begin(), PassList.end()); |
| 31 | |
Misha Brukman | 46e18d4 | 2003-09-12 20:42:57 +0000 | [diff] [blame^] | 32 | // Bugpoint has the ability of generating a plethora of core files, so to |
| 33 | // avoid filling up the disk, set the max core file size to 0. |
| 34 | struct rlimit rlim; |
| 35 | rlim.rlim_cur = rlim.rlim_max = 0; |
| 36 | int res = setrlimit(RLIMIT_CORE, &rlim); |
| 37 | if (res < 0) { |
| 38 | // setrlimit() may have failed, but we're not going to let that stop us |
| 39 | perror("setrlimit: RLIMIT_CORE"); |
| 40 | } |
| 41 | |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 42 | return D.run(); |
| 43 | } |