[llvm] [DebugInfo] Don't apply is_stmt on MBB branches that preserve lines (PR #108251)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 09:48:41 PST 2024


SLTozer wrote:

> Is there a reason for examining successors of interesting blocks found, instead of examining the predecessor of all blocks? Somehow the latter feels more natural to me; I don't think there's a technical reason for doing it like that though.

The reason we work from the predecessors is that we need to run `analyzeBranch` on the predecessor to get the correct behaviour, and depending on the output of that we may have different outgoing lines to different successors, so it's best to do all the successors for a predecessor at once than to either repeat the check for some MBBs multiple times or to cache the results of analyzeBranch.

We could use RPO, but it would probably be just as or more efficient to just add a slightly-faster early exit at the top of the loop - it's trivial to check for each predecessor whether any of its successors are in the `PotentialIsStmtMBBInstrs` set. In any case, right now the performance cost seems to be pretty low - I think the most important thing is that we never perform unnecessary linear scans, which the earlier-exit should achieve.

https://github.com/llvm/llvm-project/pull/108251


More information about the llvm-commits mailing list