-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen: Fix 'multiple definitions of symbol' error for functions with @_backDeploy
containing defer blocks
#62444
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
swift-ci
merged 2 commits into
swiftlang:main
from
tshortli:back-deploy-attr-duplicate-symbols-error
Dec 8, 2022
Merged
SILGen: Fix 'multiple definitions of symbol' error for functions with @_backDeploy
containing defer blocks
#62444
swift-ci
merged 2 commits into
swiftlang:main
from
tshortli:back-deploy-attr-duplicate-symbols-error
Dec 8, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ktoso
approved these changes
Dec 7, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to make sense, thank you @tshortli !
2f6b024
to
2dd809c
Compare
@swift-ci please test |
… `@_backDeploy` containing defer blocks. If the emission of a function is delayed via `emitOrDelayFunction()`, then the function is recorded on a list of delayed functions. If the delayed function is later referenced, then the function moves from the delayed list to the "forced" list which will cause it to actually be emitted later. The implementation of `emitOrDelayFunction()` had a bug when called twice for the same delayable function - it would emit that function prematurely if the function moved to the forced list between the two invocations. Later, during forced function emission a multiple definitions of symbol diagnostic would be emitted since the function was not empty. This issue could be triggered by `@_backDeploy` functions that have auxilary delayable helper functions (e.g. defer blocks). SILGen visits `@_backDeploy` functions twice (once for the copy of the function emitted into the client and once for the resilient copy of the function) so `emitOrDelayFunction()` is called twice for each of the helper functions and the helper functions could become referenced between the two calls. The fix is to check for an existing entry in the forced functions list before delaying or emitting a delayable function. Resolves rdar://102909684
2dd809c
to
95a9310
Compare
@swift-ci please smoke test and merge |
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Jan 10, 2023
Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (swiftlang#62444) and for now we need the standard library interface to be compatible with those older compilers. Resolves rdar://104045168
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Jan 10, 2023
…tandard library. Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (swiftlang#62444) and for now we need the standard library interface to be compatible with those older compilers. Resolves rdar://104045168
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Jan 10, 2023
…tandard library. Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (swiftlang#62444) and for now we need the standard library interface to be compatible with those older compilers. Resolves rdar://104045168
This was referenced Jan 10, 2023
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Jan 10, 2023
…tandard library. Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (swiftlang#62444) and for now we need the standard library interface to be compatible with those older compilers. Resolves rdar://104045168
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Jan 10, 2023
…tandard library. Older versions of the 5.8 compiler have a bug when generating SIL for functions with `@_backDeploy` containing defer blocks (swiftlang#62444) and for now we need the standard library interface to be compatible with those older compilers. Resolves rdar://104045168
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the emission of a function is delayed via
emitOrDelayFunction()
, then the function is recorded on a list of delayed functions. If the delayed function is later referenced, then the function moves from the delayed list to the "forced" list which will cause it to actually be emitted later. The implementation ofemitOrDelayFunction()
had a bug when called twice for the same delayable function - it would emit that function prematurely if the function moved to the forced list between the two invocations. Later, during forced function emission a multiple definitions of symbol diagnostic would be emitted since the function was not empty.This issue could be triggered by
@_backDeploy
functions that have auxilary delayable helper functions (e.g. defer blocks). SILGen visits@_backDeploy
functions twice (once for the copy of the function emitted into the client and once for the resilient copy of the function) soemitOrDelayFunction()
is called twice for each of the helper functions and the helper functions could become referenced between the two calls.The fix is to check for an existing entry in the forced functions list before delaying or emitting a delayable function.
Resolves rdar://102909684