//===----------------------------------------------------------------------===//
#include "BugDriver.h"
-#include "Support/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.
// 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!");
}
// 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) {
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();
}