Skip to content

Cleanup EscapeAnalysis::ConnectionGraph::initializePointsTo. #28273

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 1 commit into from
Nov 15, 2019
Merged

Cleanup EscapeAnalysis::ConnectionGraph::initializePointsTo. #28273

merged 1 commit into from
Nov 15, 2019

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Nov 14, 2019

Remove cruft that I added in the previous commit. This eliminates
unnecessary cleverness so initializePointsTo is now very simple.

Add hand-coded SIL test cases to somewhat verify that the new
algorithm works.

@atrick atrick requested a review from eeckstein November 14, 2019 22:31
@atrick
Copy link
Contributor Author

atrick commented Nov 14, 2019

@eeckstein I had added some junk to initializePointsTo in a hurry right before you reviewed it. I was trying to remove even more edges but there was no basis for doing that. This PR removes that junk. Both initializePointsTo and mergePointsTo should be utterly straightforward to read now.

This should address your review comments. You're right that this small loop is only relevant when defer-edge cycles occur:

    // For all nodes visited in step 1, if any node was not backward-reachable
    // from a pointsTo edge, create an edge for it and restart traversal. This
    // only happens when step 1 fails to find leaves in the defer web because
    // of defer edge cycles.
    while (!updatedNodes.empty()) {
      CGNode *node = updatedNodes.nodeVector.pop_back_val();
      if (!node->pointsTo) {
        pointsToEdges.push_back(node);
        break;
      }
    }

The original algorithm was problematic because it would add pointsTo edges even when no cycles exist in the graph. It would do so whenever connecting an uninitialized web to an already-initialized web.

@atrick
Copy link
Contributor Author

atrick commented Nov 14, 2019

@swift-ci test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

thanks, LGTM!

Remove cruft that I added in the previous commit. This eliminates
unnecessary cleverness so initializePointsTo is now very simple.

Add hand-coded SIL test cases to somewhat verify that the new
algorithm works.
@atrick
Copy link
Contributor Author

atrick commented Nov 15, 2019

@swift-ci smoke test

@atrick atrick merged commit 84e1d7e into swiftlang:master Nov 15, 2019
@atrick atrick deleted the escape-initializePointsTo branch December 23, 2019 03:14
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