When the user hits ctrl-c, bugpoint should attempt to stop reduction as
quickly as possible and output what it has so far.  If they hit it twice,
bugpoint is killed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22579 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp
index 3cbb4c0..a4442c7 100644
--- a/tools/bugpoint/bugpoint.cpp
+++ b/tools/bugpoint/bugpoint.cpp
@@ -32,13 +32,21 @@
 static cl::list<const PassInfo*, bool, PassNameParser>
 PassList(cl::desc("Passes available:"), cl::ZeroOrMore);
 
+/// BugpointIsInterrupted - Set to true when the user presses ctrl-c.
+bool llvm::BugpointIsInterrupted = false;
+
+static void BugpointInterruptFunction() {
+  BugpointIsInterrupted = true;
+}
+
 int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv,
                               " LLVM automatic testcase reducer. See\nhttp://"
                               "llvm.cs.uiuc.edu/docs/CommandGuide/bugpoint.html"
                               " for more information.\n");
   sys::PrintStackTraceOnErrorSignal();
-
+  sys::SetInterruptFunction(BugpointInterruptFunction);
+  
   BugDriver D(argv[0]);
   if (D.addSources(InputFilenames)) return 1;
   D.addPasses(PassList.begin(), PassList.end());