Skip to content

[silgen] When performing existential erasure, be sure that we have a … #21099

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

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Dec 6, 2018

…plus one value.

This both fixes the issue in SILGenPoly that exposed the problem and
additionally introduces a check in asserts builds to ensure that we catch this
problem in the future.

rdar://43398898

…plus one value.

This both fixes the issue in SILGenPoly that exposed the problem and
additionally introduces a check in asserts builds to ensure that we catch this
problem in the future.

rdar://43398898
@gottesmm
Copy link
Contributor Author

gottesmm commented Dec 6, 2018

@swift-ci smoke test

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Michael!

bool allowEmbeddedNSError) {
// Mark the needed conformances as used.
for (auto conformance : conformances)
SGM.useConformance(conformance);

// A wrapper around inputF that makes sure we are passed a +1 value if we are
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a hack. Why not convert it to a +1 value where necessary when you actually call F?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually isn't the +1-ness supposed to be encoded in the SGFContext? The original intent of the code was that everything produced a +1 value unless SGFContext.allowPlusZero() was true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@slavapestov I don't think it makes sense to do existential erasure on +0 value. You are producing a new value independent of the original value. That says it must be an owned value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am converting it to the +1 when calling F in the caller. This is just the callee can assert that is true in a way that should optimize out in no-asserts build.

I am fine changing the code in the caller to check the SGFContext though instead of doing ensurePlusOne.

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Yeah, Slava's right, it seems like we should be able to pass down a +1-only context to the payload generator function instead of patching things up ad-hoc.

@gottesmm
Copy link
Contributor Author

I fixed it the way you guys suggested (figuring out why we were not respecting the +1 context and making us obey said context): #23216.

@gottesmm gottesmm closed this Mar 12, 2019
@gottesmm gottesmm deleted the pr-0691e89a440e996eecb4996c8feaabac30fbd143 branch March 12, 2019 10:16
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.

3 participants