#include "llvm/Config/config.h" // for HAVE_LINK_R
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
};
}
+static void diagnosticHandler(const DiagnosticInfo &DI) {
+ DiagnosticPrinterRawOStream DP(errs());
+ DI.print(DP);
+ errs() << '\n';
+ if (DI.getSeverity() == DS_Error)
+ exit(1);
+}
+
/// TestMergedProgram - Given two modules, link them together and run the
/// program, checking to see if the program matches the diff. If there is
/// an error, return NULL. If not, return the merged module. The Broken argument
M1 = CloneModule(M1);
M2 = CloneModule(M2);
}
- if (Linker::linkModules(*M1, *M2))
+ if (Linker::linkModules(*M1, *M2, diagnosticHandler))
exit(1);
delete M2; // We are done with this module.
MisCompFunctions.emplace_back(F->getName(), F->getFunctionType());
}
- if (Linker::linkModules(*ToNotOptimize, *ToOptimizeLoopExtracted))
+ if (Linker::linkModules(*ToNotOptimize, *ToOptimizeLoopExtracted,
+ diagnosticHandler))
exit(1);
MiscompiledFunctions.clear();
// extraction both didn't break the program, and didn't mask the problem.
// Replace the current program with the loop extracted version, and try to
// extract another loop.
- if (Linker::linkModules(*ToNotOptimize, *ToOptimizeLoopExtracted))
+ if (Linker::linkModules(*ToNotOptimize, *ToOptimizeLoopExtracted,
+ diagnosticHandler))
exit(1);
delete ToOptimizeLoopExtracted;
if (!I->isDeclaration())
MisCompFunctions.emplace_back(I->getName(), I->getFunctionType());
- if (Linker::linkModules(*ProgClone, *Extracted))
+ if (Linker::linkModules(*ProgClone, *Extracted, diagnosticHandler))
exit(1);
// Set the new program and delete the old one.