This is necessary because we need to model its stack-allocation
behavior, although I'm not yet doing that in this patch because
StackNesting first needs to be taught to not try to move the
deallocation.
I'm not convinced that `async let` *should* be doing a stack allocation,
but it undoubtedly *is* doing a stack allocation, and until we have an
alternative to that, we will need to model it properly.
To enable ABIs which store extra info in the frame, add two new slots to
the coroutine allocator function table. For example, a frame could have
a header containing a context pointer at a negative offset from the
address returned from `swift_coro_alloc_frame`. The frame deallocation
function would then know to deallocate more space correspondingly.
When calling a C++ function that takes a reference to a pointer to a foreign reference type, Swift would previously pass a pointer to the foreign reference type as an argument (instead of a reference to a pointer), which resulted in invalid memory accesses.
This was observed when using `std::vector<ImmortalRef*>::push_back`.
rdar://150791778
Fixes an assertion failure in the rebranch `llvm::APInt` ctor on 32-bit
Windows. We were hitting the assertion because `uint64_t(-2)` does not
fit into 32 bits when treated as unsigned.
These assertions were enabled by default
https://github.com/llvm/llvm-project/pull/114539.
An `IRGenFunction` may not have a debug scope--for example, a dispatch
thunk--but creating an `AritificalLocation` requires one. Only create
an `ArtificalLocation` here if the `IRGenFunction` has one.
Unfortunately, I don't have an isolated test case. Fixes a compiler
crash.
If debug info generation is enabled, set debug location to the
coroutine call instruction to make sure there are no issues with invalid
debug information in LTO.
This happens because in LTO, if a call to a function doesn't contain a
debug location, we see the warning:
inlinable function call in a function with debug info must have a
!dbg location
ld: warning: Invalid debug info found, debug info will be stripped
Which then strips the debug info from the entire .o file linked into the
dylib.
Simply omit the 'nocapture' attribute on the parameter.
Fixes rdar://148039510 ([nonescapable] IRGen: lower addressable
params to LLVM: captures(ret: address, provenance))
* [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function
This commit modifies IRGen to emit a stub function `__swift_coroFrameAllocStub` instead of the
newly introduced swift-rt function `swift_coroFrameAlloc`. The stub checks whether the runtime has the symbol
`swift_coroFrameAlloc` and dispatches to it if it exists, uses `malloc` otherwise. This ensures the
ability to back deploy the feature to older OS targets.
rdar://145239850
Calls to the allocation functions use the same convention regardless of
which function, so if the functino being called is malloc and free,
provide a thunk with the appropriate convention.