Motivation: we have passes with lot of rewrites and when one one them segfaults or asserts, it is very hard to find waht exactly pattern failed without debug info.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
193 | I would consider the name as part of the pattern, i.e. the name should be set in the constructor or via a set method by the pattern itself. There shouldn't be a need to expose this to any other class. |
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
193 | This makes sense from architectural POV but I'm not sure how to achieve this. And I definitely do not want to bother pattern writers with additional ctor parameter, needed only for debug purposes. |
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
193 | I have the opposite POV. I'd rather do what's right architecturally. I don't have as much concern about pattern writers adding an additional param. |
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
193 | This is work which can and should be automated. Not to mention it will require update to all existing rewrites to be useful, which is unrealistic. Anyway, I agree that current solution is hacky and I don't have better at the moment. I guess I will just keep this as separate patch and will apply to my copy locally. |
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
193 | I don't think it's completely hacky, and I do have a need/desire for this functionality as well. What if we restructured it such that:
At that point, you can move the need for any friends (which was the part that stuck out to me most). |
I feel this is a bit "ad-hoc" and without more info here it may be a bit messy (collision, lack of naming convention, etc.) . It may not matter too much as a "debug name" use case but that could prevent other kind of use cases (filtering for example). A label system could be more flexible but "label" does not necessarily provide a unique id either. I'm not sure what'd be an ideal solution yet though.
Actually, maybe just rename those methods to get/setDebugName() or setPrettyName(), make them public and say explicitly in doc that it should be used only for debugging purposes? So 'proper' pattern name or tags can be added later separately if needed.
SGTM. I can evolve it to fit my needs in a followup.
mlir/lib/Rewrite/PatternApplicator.cpp | ||
---|---|---|
206 | Do we need to repeat the Trying to match here? Seems redundant? |
Renamed to setDebugName, moved to public, FnPattern handling
mlir/lib/Rewrite/PatternApplicator.cpp | ||
---|---|---|
206 | removed |
mlir/lib/Rewrite/PatternApplicator.cpp | ||
---|---|---|
199–200 | This is debug output, so I don't have strong opinion on this. Empty pattern name will look like Trying to match "" (empty quotes) |
Do you need someone to land this for you?
mlir/lib/Rewrite/PatternApplicator.cpp | ||
---|---|---|
199–200 | If it matters in-practice we can look at adding better defaults. |
I would consider the name as part of the pattern, i.e. the name should be set in the constructor or via a set method by the pattern itself. There shouldn't be a need to expose this to any other class.