<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58332>58332</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Unexpected behavior when using DebugActions with the same parameters
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          inkryp
      </td>
    </tr>
</table>

<pre>
    I was playing around with [DebugActionTest.cpp](https://github.com/llvm/llvm-project/blob/main/mlir/unittests/Support/DebugActionTest.cpp) and I came across this use case which I believe is not behaving how it should be:

```cpp
// Define two DebugAction with the same parameters (in this case none)
struct SimpleAction : public DebugAction<> {
  static StringRef getTag() { return "simple-action"; }
  static StringRef getDescription() { return "simple-action-description"; }
};
struct OtherAction : public DebugAction<> {
  static StringRef getTag() { return "other-action"; }
  static StringRef getDescription() { return "other-action-description"; }
};

TEST(DebugActionTest, SpecificActionHandler) {
  DebugActionManager manager;

  // Define SpecificActionHandler extending from SimpleAction
  struct SpecificActionHandler : public SimpleAction::Handler {
    FailureOr<bool> shouldExecute() final {
      return numExecutions++ < 3;
    }
    unsigned int numExecutions = 0;
  };

  manager.registerActionHandler<SpecificActionHandler>();

  EXPECT_TRUE(manager.shouldExecute<SimpleAction>());
  // Call to shouldExecute<OtherAction>() is actually handled by our newly
  // defined SpecificActionHandler, instead of GenericHandler
  EXPECT_TRUE(manager.shouldExecute<OtherAction>());
  EXPECT_TRUE(manager.shouldExecute<SimpleAction>());
  // This is just the third call using shouldExecute<SimpleAction>(), but
  // SpecificActionHandler was already called three times so now returns false
  EXPECT_FALSE(manager.shouldExecute<SimpleAction>());
  // shouldExecute<OtherAction>() is still being called by SpecificActionHandler
  EXPECT_FALSE(manager.shouldExecute<OtherAction>());
}
```

My intuition would have told me that only calls from `manager.shouldExecute<SimpleAction>();` would be the ones handled by `SpecificActionHandler`, but apparently this is not what is happening as showcased by the example.

Is this the intended behavior?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1Vttu2zgQ_Rr5ZRBDlmIletBDYjvdAFt0UbvAvi0oaWyxpUmBlzj--x2KViK57jYBsoAg6jI8c-ZwOJxS1cfiEQ7MQCvYkcsdMK2crOHAbQPR_H6JpdvdVZYruUFjp1XbRvNllNw21rYmSu-i5IGuHZm7clqpPb0I8dQPV61W37Gy9FoKVdKwZ1z6QXBNg5PcWsI19Lx2bau0N73kNMmBEa9HqNgegVVaGQO24QacQfpIt0PDq4YsShQcnxDon1SWXhv25ENr1AG4BdMoJ2r67NnHyyju71kcLu8ufOligyVuuUSwBwUDZkEi2yAYz6hlmgaL2gCpw2Xg1vGSSiLxD5jGaldZWPN9K_CERESgdaXg1dBBlC6idAXRzX2YCWAss2SztprC-Ypb2KHdsB358_KQIWi0ThNgkpjOwRULUEkSpfdksfwvqCWaSvM2TPgd5FU9tB7D-4f0fhTvFxJK_4_hKo__odEOEd8abLhvVusNQZ5lcZQsYN1ixbe8Cl__oIQWqE-ue66DaZ-ZZDvUsA_jmRuAcX5eBAd8tihrn_5brfajvHtVJ6TkxfmDxRrNpb2T3r0YvdIHeGBcOI1fiO-iVEr4VQ17bvWMlbN4kptIMzGeCr3-0u2DMbmi2nBPFzFZQPqigTcerDCAk4bvJNbApR3Pp5lLiAczf14y6DWeatxxY_tc7ZcoXVxeunQVgvkJbvX3X6vF5p_N12_eogcfy0CgI0V7rAHcyxovmBBgFZwjDPbVC4AvfJS3jqYcoemYUrk7gnIaJB7E8Qy77vKn_lV2LkhRUoTVoLbwCSVqXvU_3xXtJa7jYD9atY2vwXR9d8Z2pZqKsq6pKpOYzvhN8UbsBZTOnoFf3i_-LGVCk1zHzg_pahuN5Jrv0YBRdBwcTmluYMuEwbPoH-7-XH9M-G9NFmM5CVKiF-TEmdLlcjq8j-vvlvy1ivaH73AbfT76zex4OG67U5uOcpJS0dPeryazoKQISptQ4QjjfcoRlyw-wZfYp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