bugpoint.cpp revision 67b36e4a2fba4931747cad61979aa92d43002ccc
1//===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===// 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" 10#include "llvm/Support/PassNameParser.h" 11#include "Support/CommandLine.h" 12#include "Config/unistd.h" 13#include <sys/resource.h> 14 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> 23PassList(cl::desc("Passes available:"), cl::ZeroOrMore); 24 25int main(int argc, char **argv) { 26 cl::ParseCommandLineOptions(argc, argv); 27 28 BugDriver D(argv[0]); 29 if (D.addSources(InputFilenames)) return 1; 30 D.addPasses(PassList.begin(), PassList.end()); 31 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 42 return D.run(); 43} 44