summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lto
diff options
context:
space:
mode:
authorVivek Pandya <vivekvpandya@gmail.com>2017-09-15 19:30:59 +0000
committerVivek Pandya <vivekvpandya@gmail.com>2017-09-15 19:30:59 +0000
commit00d887447b05bd41ec77a897978bace2af287154 (patch)
tree7cbf2055a7483fff1223c6c911d64c2a0a9c704b /llvm/tools/lto
parentaff1c4df2573db4c21143c990db268d85350fd54 (diff)
downloadbcm5719-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/tools/lto')
-rw-r--r--llvm/tools/lto/lto.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 1b218a64cbf..11885211797 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -75,20 +75,23 @@ static bool parsedOptions = false;
static LLVMContext *LTOContext = nullptr;
-static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) {
- if (DI.getSeverity() != DS_Error) {
- DiagnosticPrinterRawOStream DP(errs());
- DI.print(DP);
- errs() << '\n';
- return;
- }
- sLastErrorString = "";
- {
- raw_string_ostream Stream(sLastErrorString);
- DiagnosticPrinterRawOStream DP(Stream);
- DI.print(DP);
+struct LTOToolDiagnosticHandler : public DiagnosticHandler {
+ bool handleDiagnostics(const DiagnosticInfo &DI) override {
+ if (DI.getSeverity() != DS_Error) {
+ DiagnosticPrinterRawOStream DP(errs());
+ DI.print(DP);
+ errs() << '\n';
+ return true;
+ }
+ sLastErrorString = "";
+ {
+ raw_string_ostream Stream(sLastErrorString);
+ DiagnosticPrinterRawOStream DP(Stream);
+ DI.print(DP);
+ }
+ return true;
}
-}
+};
// Initialize the configured targets if they have not been initialized.
static void lto_initialize() {
@@ -108,7 +111,8 @@ static void lto_initialize() {
static LLVMContext Context;
LTOContext = &Context;
- LTOContext->setDiagnosticHandler(diagnosticHandler, nullptr, true);
+ LTOContext->setDiagnosticHandler(
+ llvm::make_unique<LTOToolDiagnosticHandler>(), true);
initialized = true;
}
}
@@ -274,7 +278,8 @@ lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
// Create a local context. Ownership will be transferred to LTOModule.
std::unique_ptr<LLVMContext> Context = llvm::make_unique<LLVMContext>();
- Context->setDiagnosticHandler(diagnosticHandler, nullptr, true);
+ Context->setDiagnosticHandler(llvm::make_unique<LTOToolDiagnosticHandler>(),
+ true);
ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createInLocalContext(
std::move(Context), mem, length, Options, StringRef(path));
OpenPOWER on IntegriCloud