[PATCH][LTO] Add a hook to map LLVM diagnostics into the clients of LTO.

Quentin Colombet qcolombet at apple.com
Fri Jan 3 11:38:03 PST 2014


Hi,

This patch adds a way to register a diagnostic handler for the diagnostics coming from the code generator for the clients of LTO.

** Context **

In r197438, we introduced a new API to diagnose all sorts of events in the backend. This diagnostic framework exposes a hook to map the reported events in the client of the backend.

LTO, as a client of the backend, has access to this framework. However, LTO is not the component that directly interacts with the user. Therefore, we need to propagate these diagnostics to the clients of LTO.


** Proposed Solution **

Add a hook in the C API of LTO so that clients of the code generator can set their own handler.
The handler is defined like this:
typedef void (*lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt)
- severity says how bad this is.
- diag is a string that contains the diagnostic message.
- ctxt is the registered context for this handler.

This hook is more general than the lot_get_error_message, since this function keeps only the latest message and can only be queried when something went wrong (no warning for instance).

Finally, the patch also adds LTOCodeGenerator::resetDiagnosticHandler (and the related C API), to reset the diagnostic handler to the original one. Indeed, the original diagnostic handler (if any) uses the C++ API and there are no (clean) way to expose it in the C API.

Thanks for your reviews.

Cheers,
-Quentin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140103/7310671b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lto_diag.patch
Type: application/octet-stream
Size: 8910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140103/7310671b/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140103/7310671b/attachment-0001.html>


More information about the llvm-commits mailing list