summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-12-04 22:08:53 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-12-04 22:08:53 +0000
commitf49a38fc0887baac3a21ecebf8d13b7e416ac2c6 (patch)
tree7dfeace7a0801214395aeac03256f92c28c19dce /llvm/lib
parent8213072a453bcb012b31d231dae4f44a589ddd52 (diff)
downloadbcm5719-llvm-f49a38fc0887baac3a21ecebf8d13b7e416ac2c6.tar.gz
bcm5719-llvm-f49a38fc0887baac3a21ecebf8d13b7e416ac2c6.zip
Always pass a diagnostic handler to the linker.
Before this patch the diagnostic handler was optional. If it was not passed, the one in the LLVMContext was used. That is probably not a pattern we want to follow. If each area has an optional callback, there is a sea of callbacks and it is hard to follow which one is called. Doing this also found cases where the callback is a nice addition, like testing that no errors or warnings are reported. The other option is to always use the diagnostic handler in the LLVMContext. That has a few problems * To implement the C API we would have to set the diag handler and then set it back to the original value. * Code that creates the context might be far away from code that wants the diagnostics. I do have a patch that implements the second option and will send that as an RFC. llvm-svn: 254777
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp10
-rw-r--r--llvm/lib/Linker/LinkModules.cpp10
2 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index b0dae74c13d..25c150b2784 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -65,9 +65,10 @@ const char* LTOCodeGenerator::getVersionString() {
}
LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
- : Context(Context),
- MergedModule(new Module("ld-temp.o", Context)),
- IRLinker(new Linker(*MergedModule)) {
+ : Context(Context), MergedModule(new Module("ld-temp.o", Context)),
+ IRLinker(new Linker(*MergedModule, [this](const DiagnosticInfo &DI) {
+ MergedModule->getContext().diagnose(DI);
+ })) {
initializeLTOPasses();
}
@@ -123,7 +124,8 @@ void LTOCodeGenerator::setModule(std::unique_ptr<LTOModule> Mod) {
AsmUndefinedRefs.clear();
MergedModule = Mod->takeModule();
- IRLinker = make_unique<Linker>(*MergedModule);
+ IRLinker =
+ make_unique<Linker>(*MergedModule, IRLinker->getDiagnosticHandler());
const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
for (int I = 0, E = Undefs.size(); I != E; ++I)
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 55ab1824740..88b8e443c48 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -2030,11 +2030,6 @@ Linker::Linker(Module &M, DiagnosticHandlerFunction DiagnosticHandler)
}
}
-Linker::Linker(Module &M)
- : Linker(M, [this](const DiagnosticInfo &DI) {
- Composite.getContext().diagnose(DI);
- }) {}
-
bool Linker::linkInModule(Module &Src, unsigned Flags,
const FunctionInfoIndex *Index,
DenseSet<const GlobalValue *> *FunctionsToImport) {
@@ -2061,11 +2056,6 @@ bool Linker::linkModules(Module &Dest, Module &Src,
return L.linkInModule(Src, Flags);
}
-bool Linker::linkModules(Module &Dest, Module &Src, unsigned Flags) {
- Linker L(Dest);
- return L.linkInModule(Src, Flags);
-}
-
//===----------------------------------------------------------------------===//
// C API.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud