https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89099
--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> --- Indeed: -fopt-info is currently implemented via writing to up to two FILE * destinations: the dumpfile and the opt-info destination (e.g. stderr). In particular it doesn't go through the diagnostic subsystem. Some of the differences between dumping and diagnostics: * as noted in comment #0, it's missing the quoted source code * it's missing the announcements about function names, such as the: "In function 'main':" from the diagnostic example; for diagnostics this can include things like printing the inlining chain * we don't have quotes and bold in the opt-info output (e.g. via "%qs") * we don't localize the messages Two approaches to addressing this: (a) unify the two, so that -fopt-info messages (b) hack in a call to diagnostic_show_locus into the dump subsystem (this seems easier) Approach (b) seems easier. It sounds like you want this for the -fopt-info destination (alt_dump_file; typically stderr). Should diagnostic_show_locus be called for the dumpfile as well? There are some warts involving things like: * whether colorization should happen (if writing to a "real" file rather than stderr) * the cache for suppressing what was last printed, since there'd be multiple output sources * probably things I haven't thought of [perhaps the dump subsystem would need its own diagnostic_context for handling such output???]