Skip to content

[GSB] Ensure that term rewriting rules produce correct anchors #14685

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 4 commits into from
Feb 17, 2018

Conversation

DougGregor
Copy link
Member

Rework the way that we form term rewriting rules in the GenericSignatureBuilder, such that we form rewrite rules only when merging two equivalence classes, in which case we form a rewrite rule from the anchor of one equivalence class to the anchor of the other equivalence class. This produces smaller sets of rewrite rules (by far) and ensures that we always canonicalize to the anchor.

While here, fix a problem where we failing to apply rewrite rules like tau_0_1 -> tau_0_0. With both changes in, introduce assertions to make sure we're getting a proper anchor.

Fixes rdar://problem/37469390.

Although we were properly recording rewrite rules like tau_0_1 -> tau_0_0
in the rewrite tree, we were failing to apply them, so tau_0_1 wouldn’t
get properly canonicalized. Fix this, and add some assertions to make sure
we catch this with our current test suite.

Fixes rdar://problem/37469390.
@DougGregor
Copy link
Member Author

@swift-ci please test and merge

…lasses.

Instead of representing every same-type constraint we see as a rewrite rule,
only record rewrite rules when we merge equivalence classes, and record
rules that map the between the anchors of the equivalence classes. This
gives us fewer, smaller rewrite rules that (by construction) build correct
anchors.
@DougGregor DougGregor force-pushed the gsb-rewrite-rule-anchor branch from 20cc6cc to bd266b0 Compare February 16, 2018 23:10
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor DougGregor merged commit 3184dd8 into swiftlang:master Feb 17, 2018
@DougGregor DougGregor deleted the gsb-rewrite-rule-anchor branch February 17, 2018 00:02
updatedAnchor = true;

#if NDEBUG
break;
Copy link
Member

Choose a reason for hiding this comment

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

@DougGregor this introduced a warning in no-assert builds about the loop only going round once. If you have a preferred suggested way to fix that, I'll raise a PR to do it.

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