]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add publish/subscribe topics and channel: pass_events
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 9 Jan 2026 20:54:15 +0000 (15:54 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 9 Jan 2026 20:54:15 +0000 (15:54 -0500)
commit4a2e1c31159aab4bde1990589ccab0da2436dfad
treefd4d594a3d3b37bd0a97143d2fb9899df84d8a20
parentb34dad6d185a2d1b332e07ce307938bd7a0d68d3
Add publish/subscribe topics and channel: pass_events

This patch adds a new "struct compiler_channels" to hold channels
relating to the compiler that plugins (or diagnostic sinks) might want
to subscribe to events for, accessed from the global gcc::context
object, along with a new gcc/topics/ source subdirectory to hold
strongly-typed publish/subscribe topics relating to the compiler.

For now, there is just one: pass_events_channel, which, if there are any
subscribers, issues notifications about passes starting/stopping on
particular functions, using topics::pass_events, declared in
topics/pass-events.h, but followup patches add more kinds of
notification channel.

A toy plugin in the testsuite shows how this could be used to build a
progress notification UI for the compiler, and a followup patch uses the
channel to (optionally) capture CFG information at each stage of
optimization in machine-readable form into a SARIF sink.

gcc/ChangeLog:
* channels.h: New file.
* context.cc: Define INCLUDE_LIST.  Include "channels.h".
(gcc::context::context): Create m_channels.
(gcc::context::~context): Delete it.
* context.h (struct compiler_channels): New forward decl.
(gcc::context::get_channels): New accessor.
(gcc::context::m_channels): New field.
* passes.cc: Define INCLUDE_LIST.  Include "topics/pass-events.h"
and "channels.h".
(execute_one_pass): If the global context's pass_events_channel
has subscribers, publish before_pass and after_pass events to it.
* topics/pass-events.h: New file.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/plugin.exp: Add progress_notifications_plugin.cc.
* gcc.dg/plugin/progress_notifications_plugin.cc: New test plugin.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/channels.h [new file with mode: 0644]
gcc/context.cc
gcc/context.h
gcc/passes.cc
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/testsuite/gcc.dg/plugin/progress_notifications_plugin.cc [new file with mode: 0644]
gcc/topics/pass-events.h [new file with mode: 0644]