Teach bugpoint to kill optimization passes that run over the timeout limit,
authorChris Lattner <sabre@nondot.org>
Tue, 13 Jun 2006 03:10:48 +0000 (03:10 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Jun 2006 03:10:48 +0000 (03:10 +0000)
which allows it to debug optimizer infinite loops.  This patch is contributed
by Nick Lewycky, thanks!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28763 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.cpp
tools/bugpoint/BugDriver.h
tools/bugpoint/ExecutionDriver.cpp
tools/bugpoint/OptimizerDriver.cpp
tools/bugpoint/bugpoint.cpp

index 8251ee4e3fac2da3d675529b5cc3b0d53ea5de49..f8beb2a64c2ed7d25e946193688c3d081148d4fd 100644 (file)
@@ -62,9 +62,10 @@ std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
   return Result;
 }
 
-BugDriver::BugDriver(const char *toolname, bool as_child)
+BugDriver::BugDriver(const char *toolname, bool as_child, unsigned timeout)
   : 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
index 565a382d20a0e7fc95cbe6aebb5849e90f8a69e4..ec687b3c7bc0efb343927e1ae27a02fa95e5c7a7 100644 (file)
@@ -48,13 +48,14 @@ class BugDriver {
   CBE *cbe;
   GCC *gcc;
   bool run_as_child;
+  unsigned Timeout;
 
   // FIXME: sort out public/private distinctions...
   friend class ReducePassList;
   friend class ReduceMisCodegenFunctions;
 
 public:
-  BugDriver(const char *toolname, bool as_child);
+  BugDriver(const char *toolname, bool as_child, unsigned timeout);
 
   const std::string &getToolName() const { return ToolName; }
 
index 72e564ec3c09d17f5ce9766600f6ac7b9c4a1aee..5743804a146bfce2dac4ef4afe98d9090cdc40d3 100644 (file)
@@ -63,11 +63,6 @@ namespace {
                 cl::desc("Additional shared objects to load "
                          "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>
     AdditionalLinkerArgs("Xlinker", 
       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)
     RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
                                 OutputFile, AdditionalLinkerArgs, SharedObjs, 
-                                TimeoutValue);
+                                Timeout);
   else 
     RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
                                 OutputFile, std::vector<std::string>(), 
-                                SharedObjs, TimeoutValue);
+                                SharedObjs, Timeout);
 
   if (RetVal == -1) {
     std::cerr << "<timeout>";
index 37e2f74f45d152cec76e126888aa9bbfee3510ad..6caced779b53d48234a75674a9875276056cf4da 100644 (file)
@@ -179,7 +179,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
   args[n++] = 0;
 
   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,
   // remove it now.  This may fail if the file was never created, but that's ok.
index 21a462318124ae766c4b415cd623f2957a5a6292..cc05fea65086e936ed306d640aa28496a021ba5e 100644 (file)
@@ -36,6 +36,11 @@ static cl::list<std::string>
 InputFilenames(cl::Positional, cl::OneOrMore,
                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
 // PassNameParser.
 //
@@ -57,7 +62,7 @@ int main(int argc, char **argv) {
   sys::PrintStackTraceOnErrorSignal();
   sys::SetInterruptFunction(BugpointInterruptFunction);
   
-  BugDriver D(argv[0],AsChild);
+  BugDriver D(argv[0],AsChild,TimeoutValue);
   if (D.addSources(InputFilenames)) return 1;
   D.addPasses(PassList.begin(), PassList.end());