This revision adds the infrastructure for Debug Actions. This is a DEBUG only
API that allows for external entities to control various aspects of compiler
execution. This is conceptually similar to something like DebugCounters in LLVM, but at a lower level. This framework doesn't make any assumptions about how the higher level driver is controlling the execution, it merely provides a framework for connecting the two together. This means that on top of DebugCounter functionality, we could also provide more interesting drivers such as interactive execution. A high level overview of the workflow surrounding debug actions is
shown below:
- Compiler developer defines an action that is taken by the a pass, transformation, utility that they are developing.
- Depending on the needs, the developer dispatches various queries, pertaining to this action, to an action manager that will provide an answer as to what behavior the action should do.
- An external entity registers an action handler with the action manager, and provides the logic to resolve queries on actions.
The exact definition of an external entity is left opaque, to allow for more
interesting handlers.
This framework was proposed here: https://llvm.discourse.group/t/rfc-debug-actions-in-mlir-debug-counters-for-the-modern-world
Something that wasn't clear to me when reading this was how would the developer define the queries. It turns out there is a pre-defined fixed list of queries that are available globally on the action manager for all possible actions.