#include "BugDriver.h"
#include "ToolRunner.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
#include "llvm/Pass.h"
LLVMContext& ctxt)
: Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
Program(nullptr), Interpreter(nullptr), SafeInterpreter(nullptr),
- gcc(nullptr), run_find_bugs(find_bugs), Timeout(timeout),
+ cc(nullptr), run_find_bugs(find_bugs), Timeout(timeout),
MemoryLimit(memlimit), UseValgrind(use_valgrind) {}
BugDriver::~BugDriver() {
if (Interpreter != SafeInterpreter)
delete Interpreter;
delete SafeInterpreter;
- delete gcc;
+ delete cc;
}
std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename,
return Result;
}
+ if (verifyModule(*Result, &errs())) {
+ errs() << "bugpoint: " << Filename << ": error: input module is broken!\n";
+ return std::unique_ptr<Module>();
+ }
+
// If we don't have an override triple, use the first one to configure
// bugpoint, or use the host triple if none provided.
if (TargetTriple.getTriple().empty()) {
return Result;
}
+static void diagnosticHandler(const DiagnosticInfo &DI) {
+ DiagnosticPrinterRawOStream DP(errs());
+ DI.print(DP);
+ errs() << '\n';
+}
+
// This method takes the specified list of LLVM input files, attempts to load
// them, either as assembly or bitcode, then link them together. It returns
// true on failure (if, for example, an input bitcode file could not be
if (!M.get()) return true;
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
- if (Linker::LinkModules(Program, M.get()))
+ if (Linker::linkModules(*Program, *M, diagnosticHandler))
return true;
}