LTO front end now supports diagnostic pragmas
Link-Time Optimization front end can now process and stream diagnostic pragmas, improving build control.
The LTO front end has been enhanced to support compiler diagnostic pragmas, such as #pragma GCC diagnostic. This change ensures that diagnostic settings are correctly streamed and reconstructed during the LTO process, even when functions are distributed across multiple LTO sections. New test cases verify this functionality.
In Details
The LTO streamer (lto-streamer-out.cc and lto-streamer-in.cc) now handles diagnostic pragmas by streaming them within linemap sections. The existing diagnostic infrastructure is leveraged because the reconstructed linemaps maintain the correct ordering. A key consideration is how pragmas are merged when a function is streamed in multiple sections; the current implementation keeps pragmas from the section ultimately chosen by linker resolution.
- LTO
- Link-Time Optimization. A compilation technique where optimization occurs at link time rather than during individual compilation units, allowing for inter-procedural optimizations across the entire program.
- diagnostic pragmas
- Compiler directives, like
#pragma GCC diagnostic, that allow developers to control diagnostic behavior (warnings, errors, etc.) for specific code sections during compilation. - linemap
- A data structure used by the compiler to map intermediate code locations to source file locations (filename, line number, column number). It's crucial for generating accurate debugging information and diagnostics.