[all-commits] [llvm/llvm-project] 7fbcf1: Change the DebugAction paradigm to delegate the co...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Mon Mar 6 06:59:39 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7fbcf10e2e7a408dc551cab5c180ebc2fb679454
      https://github.com/llvm/llvm-project/commit/7fbcf10e2e7a408dc551cab5c180ebc2fb679454
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2023-03-06 (Mon, 06 Mar 2023)

  Changed paths:
    M mlir/include/mlir/Support/DebugAction.h
    M mlir/include/mlir/Support/DebugCounter.h
    M mlir/lib/Support/DebugCounter.cpp
    M mlir/unittests/Support/DebugActionTest.cpp
    M mlir/unittests/Support/DebugCounterTest.cpp

  Log Message:
  -----------
  Change the DebugAction paradigm to delegate the control to the handler

At the moment, we invoke `shouldExecute()` that way:

```
if (manager.shouldExecute<DebugAction>(currentOp) {
  // apply a transformation
  …
}
```

In this sequence, the manager isn’t involved in the actual execution
of the action and can’t develop rich instrumentations. Instead the API
could let the control to the handler itself:

```
// Execute the action under the control of the manager
manager.execute<DebugAction>(currentOp, [&]() {
  // apply the transformation in this callback
  …
});
```

This inversion of control (by injecting a callback) allows handlers to
implement potentially new interesting features: for example, snapshot
the IR before and after the action, or record an action execution time.
More importantly, it will allow to capture the nesting execution of
actions.

On the other side: handlers receives now a DebugAction object that wraps
generic information (tag and description especially) as well as
action-specific data.

Finally, the DebugActionManager is now enabled in release builds as
well.

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




More information about the All-commits mailing list