6.2: [TypeLowering] Record packs used in signatures. #81659
Merged
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.
Explanation: Fix a compiler crash involving a stored propoerty of variadic type substituted with a non-variadic type.
Metadata packs are stored on the stack as an optimization. These allocations must obey stack discipline. This is enforced via the PackMetadataMarkerInserter pass. That pass inserts
alloc_pack_metadata
marker instructions before each instruction which may allocate an on-stack pack and insertsdealloc_pack_metadata
instructions to indicate where those packs should be deallocated (theStackNesting
utility ensures proper nesting, reflowing all stack deallocating instructions as needded). The pass relies on knowing whether an instruction may allocate an on-stack pack. This is determined by a recursive walk over the fields of each type of each operand of the instruction. That walk is done in TypeLowering.Previously, the walk only regarded a type as involving a pack if it contained a pack in its storage. This was sufficient for non-resilient types because the metadata was not needed for types like
S<each T>
wheneach T
was not stored (recursively). This doesn't work with resilient types however, whose storage is not known during the walk. The metadata for resilient structS<each T>
is still required.Here, this is fixed by extending the condition under which a type is said to have a have a pack. In addition to considering a type which is itself a pack and types which store a pack, now types which have a pack in their signature are considered to have a pack as well.
Scope: Affects variadic generics across resilience boundaries.
Issue: rdar://147207926
Original PR: #81581
Risk: Low, this just makes the de/alloc_pack_metadata marker instructions be emitted slightly more frequently.
Testing: Added test.
Reviewer: Arnold Schwaighofer ( @aschwaighofer )