diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-01 18:36:03 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-01 18:36:03 +0000 |
| commit | 30c9242caad0f82daedb838d73d8311e82b9201b (patch) | |
| tree | df8e941e2ce9e084594f67a817db3d3a02c0e87e /llvm/tools | |
| parent | 847b37ec8aba3bf05db304358bc01beb46b16d17 (diff) | |
| download | bcm5719-llvm-30c9242caad0f82daedb838d73d8311e82b9201b.tar.gz bcm5719-llvm-30c9242caad0f82daedb838d73d8311e82b9201b.zip | |
LTO: Ignore disabled diagnostic remarks
r206400 and r209442 added remarks that are disabled by default.
However, if a diagnostic handler is registered, the remarks are sent
unfiltered to the handler. This is the right behaviour for clang, since
it has its own filters.
However, the diagnostic handler exposed in the LTO API receives only the
severity and message. It doesn't have the information to filter by pass
name. For LTO, disabled remarks should be filtered by the producer.
I've changed `LLVMContext::setDiagnosticHandler()` to take a `bool`
argument indicating whether to respect the built-in filters. This
defaults to `false`, so other consumers don't have a behaviour change,
but `LTOCodeGenerator::setDiagnosticHandler()` sets it to `true`.
To make this behaviour testable, I added a `-use-diagnostic-handler`
command-line option to `llvm-lto`.
This fixes PR21108.
llvm-svn: 218784
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index 2f19090dfc9..2bfd9594555 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -38,6 +38,10 @@ static cl::opt<bool> DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false), cl::desc("Do not run the GVN load PRE pass")); +static cl::opt<bool> +UseDiagnosticHandler("use-diagnostic-handler", cl::init(false), + cl::desc("Use a diagnostic handler to test the handler interface")); + static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore, cl::desc("<input bitcode files>")); @@ -63,6 +67,25 @@ struct ModuleInfo { }; } +void handleDiagnostics(lto_codegen_diagnostic_severity_t Severity, + const char *Msg, void *) { + switch (Severity) { + case LTO_DS_NOTE: + errs() << "note: "; + break; + case LTO_DS_REMARK: + errs() << "remark: "; + break; + case LTO_DS_ERROR: + errs() << "error: "; + break; + case LTO_DS_WARNING: + errs() << "warning: "; + break; + } + errs() << Msg << "\n"; +} + int main(int argc, char **argv) { // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(); @@ -84,6 +107,9 @@ int main(int argc, char **argv) { LTOCodeGenerator CodeGen; + if (UseDiagnosticHandler) + CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr); + switch (RelocModel) { case Reloc::Static: CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_STATIC); |

