When constructing canonical relationships between two regions, the first instruction of a basic block from the first region is used to find the corresponding basic block from the second region. However, debug instructions are not included in similarity matching, and therefore do not have a canonical numbering. This patch makes sure to ignore the debug instructions when finding the first instruction in a basic block.
Details
Diff Detail
Event Timeline
Thanks for the patch. I've verified that it solves the problem I found.
No comments about the patch itself really. Looks nice, but I don't know that much about this analysis pass to say if it is correct to skip dbg intrinsics like this. (And should for example lifetime instrinsics be skipped in the same way?)
I don't know that much about this analysis pass to say if it is correct to skip dbg intrinsics like this. (And should for example lifetime instrinsics be skipped in the same way?)
Lifetime intrinsics are currently excluded from being matched for similarity, but that's mostly because it causes problems for the outliner. Debug instructions are allowed to be in an outlined region, but are not used in the similarity matching itself. This is mostly because the IRSimilarityIdentifier was built for the outliner, but there has been some discussion about separating the two further and building a specific Identifier for the outliner itself and then one for general similarity. This is (yet another) piece that might push that decision.
LGTM
I think that debug info handling might be a good argument for splitting the similarity identifier into a similarity finding version + outlining version. The outliner needs to be considerate about what it does to debug info, but the similarity identifier doesn't. Someone very well may want to ask questions about debug info similarity in the future.