-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] Dealloc on-stack metadata/wtable packs on the dominance frontier. #66201
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 20 commits into
swiftlang:main
from
nate-chandler:dealloc-on-stack-packs
Jun 5, 2023
Merged
[IRGen] Dealloc on-stack metadata/wtable packs on the dominance frontier. #66201
swift-ci
merged 20 commits into
swiftlang:main
from
nate-chandler:dealloc-on-stack-packs
Jun 5, 2023
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
c37d161
to
abc6973
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
The source compat failures match the baseline failures. |
aschwaighofer
approved these changes
May 31, 2023
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.
LGTM
slavapestov
reviewed
Jun 1, 2023
slavapestov
reviewed
Jun 1, 2023
1f206f7
to
c3cb49d
Compare
@swift-ci please test |
If the -enable-pack-metadata-stack-promotion[=true] flag is passed, skip eager heapification.
Provide template instantiations of llvm::DenseMapInfo at swift::irgen::Address and swift::irgen::StackAddress.
Just pull the notion that the alloc corresponds to operand 0 into a helper method.
Stop requiring that allocation instructions produce single values.
Both stackAlloc and unprotectedStackAlloc are paired with stackDealloc builtins.
The algorithm requires no critical edges, but that doesn't mean require ownership. Remove the assert to allow the utility to be called from code where the caller has manually split edges. In the fullness of time, there should no passes should introduce critical edges.
The new alloc_pack_metadata and dealloc_pack_metadata are inserted as part of IRGen lowering. The former indicates that the next instruction might result in on-stack pack metadata being emitted. The latter indicates that this is the position at which metadata emitted on behalf of its operand should be cleaned up.
When lowering a SIL function, if it bears the no_onstack_pack_metadata annotation, disable on-stack pack metadata.
Deallocate dynamic allocas done for metadata/wtable packs. These stackrestore calls are inserted on the dominance frontier and then stack nesting is fixed up. That was achieved as follows: Added a new IRGen pass PackMetadataMarkerInserter; it - determines if there are any instructions which might allocate on-stack pack metadata - if there aren't, no changes are made - if there are, alloc_pack_metadata just before instructions that could allocate pack metadata on the stack and dealloc_pack_metadata on the dominance frontier of those instructions - fixup stack nesting During IRGen, the allocations done for metadata/wtable packs are recorded and IRGenSILFunction associates them with the instruction that lowered. It must be the instruction after some alloc_pack_metadata instruction. Then, when visiting the dealloc_pack_metadata instructions corresponding to that alloc_pack_metadata, deallocate those packs.
In debug builds, before SIL function emission, pass over the function to collect cleanups. After emitting an instruction for which an on-stack metadata/wtable pack was emitted, assert that there were cleanups for it in the function.
Rather than emitting markers for every single instruction of the relevant sorts, check whether the instructions' types involve packs. Only record them as potential on-stack pack metadata emitters if they do.
Set the flag and updated the tests.
c3cb49d
to
c5699c9
Compare
@swift-ci please test and merge |
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.
Deallocate dynamic allocas done for metadata/wtable packs. These
stackrestore
calls are inserted on the dominance frontier and then stack nesting is fixed up. That was achieved as follows:Added a new IRGen pass
PackMetadataMarkerInserter
; italloc_pack_metadata
just before instructions that could allocate pack metadata on the stack anddealloc_pack_metadata
on the dominance frontier of those instructionsDuring IRGen, the allocations done for metadata/wtable packs are recorded and
IRGenSILFunction
associates them with the instruction that lowered. It must be the instruction after somealloc_pack_metadata
instruction. Then, when visiting thedealloc_pack_metadata
instructions corresponding to thatalloc_pack_metadata
, deallocate those packs.See individual commits for more details.
rdar://110268881