Skip to content

[Profiler] Avoid introducing empty unreachable regions #60579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2022

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Aug 16, 2022

When computing the counter for the region following a labeled statement such as if, avoid adding a new empty region if the counter for such a region is known to be zero, i.e unreachable. This avoids adding spurious unreachable regions after an if statements where each branch returns, throws, or otherwise jumps to a parent statement.

We will however still add the region if any code follows such a statement, making it non-empty.

rdar://29390569
Resolves #43037

Refactor `CounterExpr::expand` to accept a function
lookup for the counter indices, and add
`isSemanticallyZero` to allow for checking whether
a simplified counter is 0.
When computing the counter for the region
following a labeled statement such as `if`, avoid
adding a new empty region if the counter for such
a region is known to be zero, i.e unreachable.
This avoids adding spurious unreachable regions
after an if statements where each branch returns,
throws, or otherwise jumps to a parent statement.

We will however still add the region if any code
follows such a statement, making it non-empty.

rdar://29390569
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit a1d3884 into swiftlang:main Aug 19, 2022
@hamishknight hamishknight deleted the never-say-never branch August 19, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SR-420] Incorrect Code Coverage for Optional Binding with Else Statement
1 participant