6.0: [IRGen] Deadends don't need dealloc_pack_metadata. #73236
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 false-positive assertion failure for variadic generics.
When a SIL instruction involving variadic generic types is lowered, pack metadata may be allocated. As an optimization, that metadata is allocated on the stack. To correctly nest these on-stack pack allocations, there are matching
alloc_pack_metadata
anddealloc_pack_metadata
instructions.To catch issues with bad nesting, some verification is run in asserts builds during IRGen. This patch corrects a false positive that was being flagged by that verification.
Specifically, the verification was checking that for any
alloc_pack_metadata
instruction for which metadata was indeed allocated during IRGen that there was at least one matchingdealloc_pack_metadata
instruction which would clean it up. Such a cleanup instruction need not and does not exist, however, if thealloc_pack_metadata
is in a "dead end block" (all paths passing through thealloc_pack_metadata
instruction end inunreachable
--caused, for example, by a call tofatalError()
). This patch adds a check for whether thealloc_pack_metadata
instruction is in a dead end block and does not require there to be a matchingdealloc_pack_metadata
if so.Scope: Affects asserts builds only. Affects variadic generic code.
Issue: rdar://125265980
Original PR: #73191
Risk: Very low. Only affects asserts builds.
Testing: Added regression test.
Reviewer: Arnold Schwaighofer ( @aschwaighofer )