diff options
author | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:30:59 +0000 |
---|---|---|
committer | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:30:59 +0000 |
commit | 00d887447b05bd41ec77a897978bace2af287154 (patch) | |
tree | 7cbf2055a7483fff1223c6c911d64c2a0a9c704b /llvm/lib/LTO/LTOCodeGenerator.cpp | |
parent | aff1c4df2573db4c21143c990db268d85350fd54 (diff) | |
download | bcm5719-llvm-00d887447b05bd41ec77a897978bace2af287154.tar.gz bcm5719-llvm-00d887447b05bd41ec77a897978bace2af287154.zip |
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352
It enables OptimizationRemarkEmitter::allowExtraAnalysis and MachineOptimizationRemarkEmitter::allowExtraAnalysis to return true not only for -fsave-optimization-record but when specific remarks are requested with
command line options.
The diagnostic handler used to be callback now this patch adds a class
DiagnosticHandler. It has virtual method to provide custom diagnostic handler
and methods to control which particular remarks are enabled.
However LLVM-C API users can still provide callback function for diagnostic handler.
llvm-svn: 313382
Diffstat (limited to 'llvm/lib/LTO/LTOCodeGenerator.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 8ad3cccf8d4..ee9c70126b8 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -622,12 +622,8 @@ void LTOCodeGenerator::parseCodeGenDebugOptions() { } } -void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI, - void *Context) { - ((LTOCodeGenerator *)Context)->DiagnosticHandler2(DI); -} -void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) { +void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI) { // Map the LLVM internal diagnostic severity to the LTO diagnostic severity. lto_codegen_diagnostic_severity_t Severity; switch (DI.getSeverity()) { @@ -657,17 +653,29 @@ void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) { (*DiagHandler)(Severity, MsgStorage.c_str(), DiagContext); } +namespace { +struct LTODiagnosticHandler : public DiagnosticHandler { + LTOCodeGenerator *CodeGenerator; + LTODiagnosticHandler(LTOCodeGenerator *CodeGenPtr) + : CodeGenerator(CodeGenPtr) {} + bool handleDiagnostics(const DiagnosticInfo &DI) override { + CodeGenerator->DiagnosticHandler(DI); + return true; + } +}; +} + void LTOCodeGenerator::setDiagnosticHandler(lto_diagnostic_handler_t DiagHandler, void *Ctxt) { this->DiagHandler = DiagHandler; this->DiagContext = Ctxt; if (!DiagHandler) - return Context.setDiagnosticHandler(nullptr, nullptr); + return Context.setDiagnosticHandler(nullptr); // Register the LTOCodeGenerator stub in the LLVMContext to forward the // diagnostic to the external DiagHandler. - Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this, - /* RespectFilters */ true); + Context.setDiagnosticHandler(llvm::make_unique<LTODiagnosticHandler>(this), + true); } namespace { |