Skip to content

Verify non-critical edges in OSSA #34635

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 3 commits into from
Nov 9, 2020
Merged

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Nov 9, 2020

This allows us to start cleaning up passes that do weird things with critical edges, as long as those passes are limited to OSSA. For example, CopyProgagation was broken in this respect. Now we can write simpler OSSA passes that deal with block arguments.

Also, we can now make a clear distinction between passes that modify the CFG and those that don't. This lets us do much better at preserving analysis results across passes.

Most importantly for me, it stops the onslaught of new .sil tests with critical edges which take a lot of time to rewrite later.

There are multiple reasons this is needed.

1. Most passes do not perform CFG transformations. However, we often
need to split critical edges and remember to invalidate all SIL
analyses at the end of virtually every pass. This is very innefficient
and highly bug prone.

2. Many SIL analysis algorithms needs to reason about CFG
edges. Avoiding critical edges leads to far simpler and more efficient
designs when edges can be identified by blocks.

3. Handling block arguments on conditional branches create complexity
at the lowest level of the SIL interface. This complexity is difficult
to abstract over and bleeds until any algorithm that needs to reason
about phi operands. It's far easier to work with phis if we can easily
recover the phi operand with only a reference to the predecessor
block.

4. Attempting to preserve critical edges in high and mid level IR
blocks optimizations that otherwise have no business optimizing
branches. Branch optimization should always be defered to machine
level IR where the most relevant heuristics are employed to remove
unconditional branches. If code didn't need to be placed on a critical
edges, then a branch optimization can easily remove that code from the
critical edge.
@atrick atrick requested a review from gottesmm November 9, 2020 07:14
@atrick
Copy link
Contributor Author

atrick commented Nov 9, 2020

@swift-ci test

@atrick atrick merged commit c2b13cd into swiftlang:main Nov 9, 2020
@atrick atrick deleted the verify-critedge branch November 9, 2020 17:01
Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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.

2 participants