The preheader insertion pass only depends on the CFG. Mark it as such, which
[oota-llvm.git] / tools / bugpoint / BugDriver.cpp
index 53a8395aaf1d0372cba38bc44e4ba332eb35be35..67f59fd54d77657e98f7a6e47a2d4a094e854441 100644 (file)
@@ -7,13 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "BugDriver.h"
-#include "SystemUtils.h"
 #include "llvm/Module.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Pass.h"
 #include "llvm/Assembly/Parser.h"
+#include "llvm/Bytecode/Reader.h"
 #include "llvm/Transforms/Utils/Linker.h"
-#include "llvm/Pass.h"
 #include "Support/CommandLine.h"
+#include "Support/FileUtilities.h"
 #include <memory>
 
 // Anonymous namespace to define command line options for debugging.
@@ -54,19 +54,14 @@ std::string getPassesString(const std::vector<const PassInfo*> &Passes) {
 // blocks, making it external.
 //
 void DeleteFunctionBody(Function *F) {
-  // First, break circular use/def chain references...
-  for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
-    I->dropAllReferences();
-
-  // Next, delete all of the basic blocks.
-  F->getBasicBlockList().clear();
-  F->setLinkage(GlobalValue::ExternalLinkage);
+  // delete the body of the function...
+  F->deleteBody();
   assert(F->isExternal() && "This didn't make the function external!");
 }
 
 BugDriver::BugDriver(const char *toolname)
   : ToolName(toolname), ReferenceOutputFile(OutputFile),
-    Program(0), Interpreter(0) {}
+    Program(0), Interpreter(0), cbe(0), gcc(0) {}
 
 
 /// ParseInputFile - Given a bytecode or assembly input filename, parse and
@@ -146,7 +141,7 @@ bool BugDriver::run() {
   // was specified, make sure that the raw output matches it.  If not, it's a
   // problem in the front-end or the code generator.
   //
-  bool CreatedOutput = false, Result;
+  bool CreatedOutput = false;
   if (ReferenceOutputFile.empty()) {
     std::cout << "Generating reference output from raw program...";
     if (DebugCodegen) {
@@ -158,10 +153,14 @@ bool BugDriver::run() {
     std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
   } 
 
-  if (DebugMode == DebugCompile) {
+  bool Result;
+  switch (DebugMode) {
+  default: assert(0 && "Bad value for DebugMode!");
+  case DebugCompile:
     std::cout << "\n*** Debugging miscompilation!\n";
     Result = debugMiscompilation();
-  } else if (DebugMode == DebugCodegen) {
+    break;
+  case DebugCodegen:
     std::cout << "Debugging code generator problem!\n";
     Result = debugCodeGenerator();
   }