1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Teach bugpoint to kill optimization passes that run over the timeout limit,

which allows it to debug optimizer infinite loops.  This patch is contributed
by Nick Lewycky, thanks!

llvm-svn: 28763
This commit is contained in:
Chris Lattner 2006-06-13 03:10:48 +00:00
parent f04cf06b5a
commit 05b6364eef
5 changed files with 14 additions and 12 deletions

View File

@ -62,9 +62,10 @@ std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
return Result; return Result;
} }
BugDriver::BugDriver(const char *toolname, bool as_child) BugDriver::BugDriver(const char *toolname, bool as_child, unsigned timeout)
: ToolName(toolname), ReferenceOutputFile(OutputFile), : ToolName(toolname), ReferenceOutputFile(OutputFile),
Program(0), Interpreter(0), cbe(0), gcc(0), run_as_child(as_child) {} Program(0), Interpreter(0), cbe(0), gcc(0), run_as_child(as_child),
Timeout(timeout) {}
/// ParseInputFile - Given a bytecode or assembly input filename, parse and /// ParseInputFile - Given a bytecode or assembly input filename, parse and

View File

@ -48,13 +48,14 @@ class BugDriver {
CBE *cbe; CBE *cbe;
GCC *gcc; GCC *gcc;
bool run_as_child; bool run_as_child;
unsigned Timeout;
// FIXME: sort out public/private distinctions... // FIXME: sort out public/private distinctions...
friend class ReducePassList; friend class ReducePassList;
friend class ReduceMisCodegenFunctions; friend class ReduceMisCodegenFunctions;
public: public:
BugDriver(const char *toolname, bool as_child); BugDriver(const char *toolname, bool as_child, unsigned timeout);
const std::string &getToolName() const { return ToolName; } const std::string &getToolName() const { return ToolName; }

View File

@ -63,11 +63,6 @@ namespace {
cl::desc("Additional shared objects to load " cl::desc("Additional shared objects to load "
"into executing programs")); "into executing programs"));
cl::opt<unsigned>
TimeoutValue("timeout", cl::init(300), cl::value_desc("seconds"),
cl::desc("Number of seconds program is allowed to run before it "
"is killed (default is 300s), 0 disables timeout"));
cl::list<std::string> cl::list<std::string>
AdditionalLinkerArgs("Xlinker", AdditionalLinkerArgs("Xlinker",
cl::desc("Additional arguments to pass to the linker")); cl::desc("Additional arguments to pass to the linker"));
@ -231,11 +226,11 @@ std::string BugDriver::executeProgram(std::string OutputFile,
if (InterpreterSel == RunLLC || InterpreterSel == RunCBE) if (InterpreterSel == RunLLC || InterpreterSel == RunCBE)
RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile, RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
OutputFile, AdditionalLinkerArgs, SharedObjs, OutputFile, AdditionalLinkerArgs, SharedObjs,
TimeoutValue); Timeout);
else else
RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile, RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
OutputFile, std::vector<std::string>(), OutputFile, std::vector<std::string>(),
SharedObjs, TimeoutValue); SharedObjs, Timeout);
if (RetVal == -1) { if (RetVal == -1) {
std::cerr << "<timeout>"; std::cerr << "<timeout>";

View File

@ -179,7 +179,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
args[n++] = 0; args[n++] = 0;
sys::Path prog(sys::Program::FindProgramByName(ToolName)); sys::Path prog(sys::Program::FindProgramByName(ToolName));
int result = sys::Program::ExecuteAndWait(prog,args); int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout);
// If we are supposed to delete the bytecode file or if the passes crashed, // If we are supposed to delete the bytecode file or if the passes crashed,
// remove it now. This may fail if the file was never created, but that's ok. // remove it now. This may fail if the file was never created, but that's ok.

View File

@ -36,6 +36,11 @@ static cl::list<std::string>
InputFilenames(cl::Positional, cl::OneOrMore, InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input llvm ll/bc files>")); cl::desc("<input llvm ll/bc files>"));
static cl::opt<unsigned>
TimeoutValue("timeout", cl::init(300), cl::value_desc("seconds"),
cl::desc("Number of seconds program is allowed to run before it "
"is killed (default is 300s), 0 disables timeout"));
// The AnalysesList is automatically populated with registered Passes by the // The AnalysesList is automatically populated with registered Passes by the
// PassNameParser. // PassNameParser.
// //
@ -57,7 +62,7 @@ int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal(); sys::PrintStackTraceOnErrorSignal();
sys::SetInterruptFunction(BugpointInterruptFunction); sys::SetInterruptFunction(BugpointInterruptFunction);
BugDriver D(argv[0],AsChild); BugDriver D(argv[0],AsChild,TimeoutValue);
if (D.addSources(InputFilenames)) return 1; if (D.addSources(InputFilenames)) return 1;
D.addPasses(PassList.begin(), PassList.end()); D.addPasses(PassList.begin(), PassList.end());