swift
5b33567b - [IRGen] Use the substituted type for the async typed error slot

Commit
5 days ago
[IRGen] Use the substituted type for the async typed error slot rdar://187088035 AsyncCallEmission::setFromCallee allocated the caller's indirect typed error slot using the callee's unsubstituted function type, while the error edge of the try_apply loads the error back using the substituted error type. getCalleeTypedErrorResultSlot only reuses the cached slot if the storage type matches, and the unbound generic error type and the bound one have different LLVM struct types even though their layout is identical. So the load allocated a second, uninitialized slot: the callee wrote the error into one slot and the caller read it from the other, crashing or producing garbage when the error was used. This hit async calls to generic functions whose typed error depends on the callee's generic parameters and is too large to be returned directly, e.g. `func run() async throws(StageFailure<Self>)`. SyncCallEmission already uses the substituted type; do the same for async calls. Adds an IRGen test checking that the caller passes the slot it loads the error from, and a cross-module executable test.
Author
Committer
Parents
Loading