Skip to content

[4.0] [sil-combine] Make sure that (apply (partial_apply)) -> (apply') bail… #11261

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

…s if we have an argument with a dependent type.

What is going on here is that currently this optimization if itneeds to perform
lfietime extension always creates an alloc_stack at the beginning/end of a
function. If the object whose lifetime is being extended has a dependent type,
then the alloc_stack will be created before the dependent type exists resulting
in the compiler crashing.

rdar://33595317

…s if we have an argument with a dependent type.

What is going on here is that currently this optimization if itneeds to perform
lfietime extension always creates an alloc_stack at the beginning/end of a
function. If the object whose lifetime is being extended has a dependent type,
then the alloc_stack will be created before the dependent type exists resulting
in the compiler crashing.

rdar://33595317
@gottesmm
Copy link
Contributor Author

@swiftix Can I get a review?

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm changed the title [sil-combine] Make sure that (apply (partial_apply)) -> (apply') bail… [4.0] [sil-combine] Make sure that (apply (partial_apply)) -> (apply') bail… Jul 29, 2017
@gottesmm gottesmm requested a review from swiftix July 29, 2017 23:25
@gottesmm gottesmm added this to the Swift 4.0 milestone Jul 29, 2017
@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - ae2dae6
Test requested by - @gottesmm

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ae2dae6
Test requested by - @gottesmm

@gottesmm
Copy link
Contributor Author

I don't think that this is from my change.

@gottesmm
Copy link
Contributor Author

It is a typechecker error. Just out of paranoia I am going to try compiling again, this time clean maybe?

@gottesmm
Copy link
Contributor Author

@swift-ci clean test

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci clean test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - ae2dae6
Test requested by - @gottesmm

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ae2dae6
Test requested by - @gottesmm

@gottesmm
Copy link
Contributor Author

Copy link
Contributor

@swiftix swiftix 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
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

Mishal said that the problem here is fixed.

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 31, 2017

Explanation: This small patch stops the optimizer from transforming (apply (partial-apply)) -> (apply') when the partial apply: 1. has an address argument that needs to be lifetime extended. 2. Uses a dependent type. In such a situation, the currently the implemented algorithm would create stack locations at the beginning and end of the function to lifetime extend the address arguments. Since the type parameter does not exist at that point, and the compiler needs the type parameter to create the stack location, the compiler crashes.
Scope: This eliminates a compiler crash.
Radar (and possibly SR Issue): rdar://33595317
Risk: None. It just turns off an optimization and if the optimization was still enabled, we would crash.
Testing: I added a test to the compiler test suite that would cause the crash and verify no transformation occurs.

@gottesmm
Copy link
Contributor Author

Approved by Ted via email.

@gottesmm gottesmm merged commit d9180d2 into swiftlang:swift-4.0-branch Jul 31, 2017
@gottesmm gottesmm deleted the swift-4.0-branch_rdar33595317_1 branch July 31, 2017 22:11
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