6.2: [TypeLowering] Record pack used in aggregate signature. #82044
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 an assertion failure involving a generic, non-variadic-generic, type into which a variadic generic type is substituted.
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 insertsalloc_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 needed). 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 inTypeLowering
.Prior to #81659 , whether a type involved a pack in its signature was not considered by
TypeLowering
. Only whether the outermost type's signature involved a pack was considered by thetypeOrLayoutInvolvesPack
helper function called by the pass. This was incorrect. After that PR, whether any type visited recursively involved a pack in its signature was considered. This was achieved by adding merging the pack-ness of each intermediate and leaf type's signature into the outermost type's pack-ness. Specifically, this merging was done in eachLowerType::handle*
inTypeLowering.cpp
--these functions are the final step in computing each type's properties, so one will be called for every single type that's visited along the way.But I missed one of the
LowerType::handle*
functions. This in combination with the removal (correct) of the check intypeOrLayoutInvolvesPack
of whether the outermost type involved a pack in its signature led to a regression in certain cases such as that in the included test case.The solution, implemented here, is to merge in the pack-ness in the one
LowerType::handle*
function from which it was missing. This addresses the regression without reintroducing the wrong approach of checking the outermost type's signature which happened to work in some simple cases.Scope: Variadic generics.
Issue: rdar://152580661
Original PR: #82043
Risk: Low, this completes the pattern set in the previous PR, ensuring that all types merge pack-ness from their signatures.
Testing: Added test.
Reviewer: Arnold Schawighofer ( @aschwaighofer)