5.9: [IRGen] Cast dynamic alloca to appropriate type. #66086
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.
Description: Stop emitting invalid LLVM IR when emitting pack metadata, witness tables, and values when stack allocating packs in async and coroutine code.
To allocate stack space for these packs,
emitDynamicAlloca
is called fromGenPack
. The calling code expects the type of the returnedllvm::Value *
to beMetadata **
/WitnessTable **
. In synchronous contexts, the value was indeed typed thus. In asychronous contexts, however, it was typedi8 **
. Fix the callee to fulfill the callers' expectations by bit casting the value returned fromemitDynamicAlloca
to the type indicated by the caller.Risk: Low. There are only 9 callers of that function and of them the only callers (of which there are 3) that will see a change in behavior are in
GenPack
. For the remaining 6, this change is NFC because no bitcast is inserted when the source (i8 *
) and destination types are the same, and those all requesti8 *
.Scope: Narrow. Only affects variadic generic IR generation, and only changes its behavior in async and coroutine contexts.
Original PR: #66014
Reviewed By: Slava Pestov ( @slavapestov )
Testing: Added test case that previously triggered assertion failure.
Resolves: rdar://109540863