[all-commits] [llvm/llvm-project] 72d5af: [mlir] Add a new debug action framework.

River Riddle via All-commits all-commits at lists.llvm.org
Tue Feb 23 01:02:16 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 72d5afa4acc3cb7fdeb6ead90cc8f446a48c1f9d
      https://github.com/llvm/llvm-project/commit/72d5afa4acc3cb7fdeb6ead90cc8f446a48c1f9d
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    A mlir/docs/DebugActions.md
    M mlir/include/mlir/IR/MLIRContext.h
    A mlir/include/mlir/Support/DebugAction.h
    M mlir/lib/IR/MLIRContext.cpp
    M mlir/unittests/Support/CMakeLists.txt
    A mlir/unittests/Support/DebugActionTest.cpp

  Log Message:
  -----------
  [mlir] Add a new debug action framework.

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

Differential Revision: https://reviews.llvm.org/D84986


  Commit: dc6a84fce617ab8367a84029d4ff3c698dc57dad
      https://github.com/llvm/llvm-project/commit/dc6a84fce617ab8367a84029d4ff3c698dc57dad
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M mlir/docs/DebugActions.md
    A mlir/include/mlir/Support/DebugCounter.h
    M mlir/lib/Support/CMakeLists.txt
    A mlir/lib/Support/DebugCounter.cpp
    M mlir/lib/Support/MlirOptMain.cpp
    M mlir/unittests/Support/CMakeLists.txt
    A mlir/unittests/Support/DebugCounterTest.cpp

  Log Message:
  -----------
  [mlir] Add support for DebugCounters using the new DebugAction infrastructure

DebugCounters allow for selectively enabling the execution of a debug action based upon a "counter". This counter is comprised of two components that are used in the control of execution of an action, a "skip" value and a "count" value. The "skip" value is used to skip a certain number of initial executions of a debug action. The "count" value is used to prevent a debug action from executing after it has executed for a set number of times (not including any executions that have been skipped). For example, a counter for a debug action with `skip=47` and `count=2`, would skip the first 47 executions, then execute twice, and finally prevent any further executions.

This is effectively the same as the DebugCounter infrastructure in LLVM, but using the DebugAction infrastructure in MLIR. We can't simply reuse the DebugCounter support already present in LLVM due to its heavy reliance on global constructors (which are not allowed in MLIR). The DebugAction infrastructure already nicely supports the debug counter use case, and promotes the separation of policy and mechanism design philosophy.

Differential Revision: https://reviews.llvm.org/D96395


Compare: https://github.com/llvm/llvm-project/compare/7c9c0a87c8ae...dc6a84fce617


More information about the All-commits mailing list