blob: 25fe1a25245fe04c7b88992952fd9a5d39deeb2f [file] [log] [blame]
Chris Lattner9e97f4a2003-05-03 03:18:41 +00001//===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===//
Chris Lattner73a6bdd2002-11-20 22:28:10 +00002//
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 Lattner73a6bdd2002-11-20 22:28:10 +000010#include "llvm/Support/PassNameParser.h"
Misha Brukman0c2305b2003-08-07 21:19:30 +000011#include "Support/CommandLine.h"
Misha Brukman46e18d42003-09-12 20:42:57 +000012#include "Config/unistd.h"
13#include <sys/resource.h>
Chris Lattner73a6bdd2002-11-20 22:28:10 +000014
15static cl::list<std::string>
16InputFilenames(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//
22static cl::list<const PassInfo*, bool, PassNameParser>
Misha Brukmand792c9b2003-07-24 18:17:43 +000023PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
Chris Lattner73a6bdd2002-11-20 22:28:10 +000024
Chris Lattner73a6bdd2002-11-20 22:28:10 +000025int main(int argc, char **argv) {
26 cl::ParseCommandLineOptions(argc, argv);
27
Chris Lattner73a6bdd2002-11-20 22:28:10 +000028 BugDriver D(argv[0]);
29 if (D.addSources(InputFilenames)) return 1;
30 D.addPasses(PassList.begin(), PassList.end());
31
Misha Brukman46e18d42003-09-12 20:42:57 +000032 // 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 Lattner73a6bdd2002-11-20 22:28:10 +000042 return D.run();
43}