Skip to content

[5.1][cast-opt] Fix miscompile when we tried to optimize take_on_success that resulted in invalid IR being emitted. #25074

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

Conversation

gottesmm
Copy link
Contributor

[cast-opt] Fix miscompile when we tried to optimize take_on_success that resulted in invalid IR being emitted.

The specific problem here is that we are setting the insertion point of a
SILBuilder and not unsetting it. I fixed the problem by creating a separate
builder so the original builder stays put.

I originally came across this in my work on moving ownership stripping after the
diagnostic passes. This patch fixes it without my other changes to ease
cherry-picking to 5.1.

I also added more test coverage by expanding the test case to also handle
copy_on_success and take_always.

rdar://51093557
(cherry picked from commit ad67685)


NOTE: I also cherry-picked a small cleanup from master as well that eliminated a merge conflict on this code path. That is the first commit.

@gottesmm
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e7b36da5193c62b8d505d40d6fef913b6e5d4185

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e7b36da5193c62b8d505d40d6fef913b6e5d4185

gottesmm added 2 commits May 26, 2019 11:18
Importantly this lets us know further on in the function that as an invariant we
only can have checked_cast_addr_br.

(cherry picked from commit 13a3dbb)
…hat resulted in invalid IR being emitted.

The specific problem here is that we are setting the insertion point of a
SILBuilder and not unsetting it. I fixed the problem by creating a separate
builder so the original builder stays put.

I originally came across this in my work on moving ownership stripping after the
diagnostic passes. This patch fixes it without my other changes to ease
cherry-picking to 5.1.

I also added more test coverage by expanding the test case to also handle
copy_on_success and take_always.

rdar://51093557
(cherry picked from commit ad67685)
@gottesmm gottesmm force-pushed the swift-5.1-branch-rdar51093557 branch from e7b36da to 16e4d80 Compare May 26, 2019 18:18
@gottesmm
Copy link
Contributor Author

@swift-ci test

2 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e7b36da5193c62b8d505d40d6fef913b6e5d4185

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e7b36da5193c62b8d505d40d6fef913b6e5d4185

@gottesmm
Copy link
Contributor Author

I had to adjust a test for some differences from master -> 5.1. I put it in a separate commit on top.

@gottesmm
Copy link
Contributor Author

@swift-ci test

2 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 16e4d80

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 16e4d80

@gottesmm gottesmm requested a review from atrick May 27, 2019 04:38
@gottesmm
Copy link
Contributor Author

@atrick this is the same one from master modulo small test changes to reflect cleanups that I did not do on 5.1 but did do on master.

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

lgtm

@gottesmm gottesmm merged commit 5491c4e into swiftlang:swift-5.1-branch May 27, 2019
@gottesmm gottesmm deleted the swift-5.1-branch-rdar51093557 branch May 27, 2019 19:41
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