blob: 9e0d034b1a50495dd8f1075a33802d328ab00b1f [file] [log] [blame]
Chris Lattner9e97f4a2003-05-03 03:18:41 +00001//===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===//
John Criswell09344dc2003-10-20 17:47:21 +00002//
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//
Chris Lattner73a6bdd2002-11-20 22:28:10 +000010//
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"
Chris Lattner73a6bdd2002-11-20 22:28:10 +000018#include "llvm/Support/PassNameParser.h"
Misha Brukman0c2305b2003-08-07 21:19:30 +000019#include "Support/CommandLine.h"
Misha Brukman46e18d42003-09-12 20:42:57 +000020#include "Config/unistd.h"
21#include <sys/resource.h>
Chris Lattner73a6bdd2002-11-20 22:28:10 +000022
23static cl::list<std::string>
24InputFilenames(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//
30static cl::list<const PassInfo*, bool, PassNameParser>
Misha Brukmand792c9b2003-07-24 18:17:43 +000031PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
Chris Lattner73a6bdd2002-11-20 22:28:10 +000032
Chris Lattner73a6bdd2002-11-20 22:28:10 +000033int main(int argc, char **argv) {
Chris Lattner849619e2003-10-18 21:55:35 +000034 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");
Chris Lattner73a6bdd2002-11-20 22:28:10 +000038
Chris Lattner73a6bdd2002-11-20 22:28:10 +000039 BugDriver D(argv[0]);
40 if (D.addSources(InputFilenames)) return 1;
41 D.addPasses(PassList.begin(), PassList.end());
42
Misha Brukman46e18d42003-09-12 20:42:57 +000043 // 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
Chris Lattner73a6bdd2002-11-20 22:28:10 +000053 return D.run();
54}