There is no need to scan through all SkippedRegions when some of them are already added into MappingRegions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Unfortunately it does look like the work done in gatherSkippedRegions is O(n^2) in the number of functions, at the moment. If the goal is to speed it up, it'd be good to grab some performance numbers for some representative compile unit (the sqlite3 amalgamation is my go-to for this sort of thing).
clang/lib/CodeGen/CoverageMappingGen.cpp | ||
---|---|---|
353 | In the worst case, the work done in gatherSkippedRegions may still be n + (n-1) + ... ~ O(n^2) (I'm subtracting 1 each time the skipped regions for a function are erased). | |
356 | It'd probably be good to split the lambda out into a separate/named helper. |
(Depending on what the potential performance gains look like, it might be advisable to keep things simple with the current O(n^2) approach. Optimizing things can carry some risk -- not sure if we've already ruled this out, but e.g. perhaps there's some edge case with nested functions where we maybe don't want to erase skipped regions eagerly.)
clang/lib/CodeGen/CoverageMappingGen.cpp | ||
---|---|---|
353 | Yeah, just notice that. |
In the worst case, the work done in gatherSkippedRegions may still be n + (n-1) + ... ~ O(n^2) (I'm subtracting 1 each time the skipped regions for a function are erased).