Commit Graph

576 Commits

Author SHA1 Message Date
John McCall
13937fdb4e Merge pull request #84528 from rjmccall/async-let-runtime-realism
Model async let begin/finish as builtins in SIL
2025-11-05 10:24:46 -08:00
John McCall
a7d7970e29 Turn finishAsyncLet into a builtin.
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.
2025-11-03 16:33:40 -08:00
John McCall
ec81d7fb04 Move the responsibility for adding the special direct continuation
arguments to the CallEmission.
2025-11-03 13:45:19 -08:00
Nate Chandler
e0ead75622 [CoroutineAccessors] Use typed-malloc. 2025-10-30 03:59:18 -07:00
Nate Chandler
b4134e1106 [NFC] IRGen: Forming signatures of functions. 2025-10-30 03:59:18 -07:00
nate-chandler
9069d32078 Merge pull request #85055 from nate-chandler/general-coro/20251016/1
[CoroutineAccessors] Provide frame to de/allocation functions.
2025-10-23 20:17:52 -07:00
Nate Chandler
76881b1d52 [CoroutineAccessors] Add frame de/alloc functions.
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.
2025-10-22 21:00:17 -07:00
Nate Chandler
a2a4d22042 [NFC] IRGen: Typed this flag. 2025-10-22 13:00:38 -07:00
Meghana Gupta
25f0e2f934 [NFC] Replace @guaranteed_addr by @guaranteed_address 2025-10-20 09:05:37 -07:00
Meghana Gupta
a0c939bd3b Use @inout result convention for mutate accessors 2025-10-20 09:05:32 -07:00
nate-chandler
454160bca5 Merge pull request #84831 from nate-chandler/general-coro/20251009/1
[CoroutineAccessors] Sign de/allocation functions.
2025-10-13 20:03:09 -07:00
Nate Chandler
5a46d84640 [NFC] IRGen: Move these functions. 2025-10-10 16:31:46 -07:00
Nate Chandler
cd8144a794 [NFC] IRGen: Move these functions. 2025-10-10 16:28:52 -07:00
Meghana Gupta
ea0e0173b4 Merge pull request #84595 from meg-gupta/moreborrowaccessors
Extend borrow accessor support
2025-10-03 11:14:49 -07:00
Meghana Gupta
36f2955d39 IRGen support for GuaranteedAddress result convention 2025-10-02 07:18:27 -07:00
swift-ci
7f8473a16c Merge remote-tracking branch 'origin/main' into rebranch 2025-09-10 02:51:07 -07:00
Anton Korobeynikov
7668666ad2 Support differentiation of wrapped value modify accessors (#78794)
Some fixes for coroutines with normal results and `partial_apply` of coroutines were required.

Fixes #55084
2025-09-10 02:30:26 -07:00
swift-ci
8000d6c5ac Merge remote-tracking branch 'origin/main' into rebranch 2025-08-24 00:58:02 -07:00
Anthony Latsis
2640584847 Merge pull request #83854 from swiftlang/jepa-main2
IRGen: Mark some `llvm::APInt` constructions as signed
2025-08-24 08:42:34 +01:00
swift-ci
a81910c7b6 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-23 20:55:52 -07:00
Egor Zhdan
0a766e59ce [cxx-interop] Pass foreign reference types with correct level of indirection
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
2025-08-22 11:56:57 +01:00
Anthony Latsis
b765ade82a IRGen: Mark some llvm::APInt constructions as signed
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.
2025-08-21 19:54:52 +01:00
swift-ci
367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis
f8577a2731 IRGen: Address llvm::Type::getPointerTo deprecation
See https://github.com/llvm/llvm-project/pull/113331.
2025-07-21 12:37:15 +01:00
Anthony Latsis
6e9d9e175d ClangImporter: Conservatively handle new clang::HLSLInlineSpirvType type
See https://github.com/llvm/llvm-project/pull/134034
2025-06-13 21:57:37 +01:00
Anthony Latsis
6cbd6024cd Adjust includes of renamed Clang file
See 3a42cbd47d
(No PR?!)
2025-06-13 21:57:36 +01:00
swift-ci
a90269ebb6 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-29 14:55:33 -07:00
Nate Chandler
94e7582d93 [IRGen] This ArtificialLoc requires a debug scope.
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.
2025-05-28 11:19:03 -07:00
swift-ci
09c013502e Merge remote-tracking branch 'origin/main' into rebranch 2025-05-13 17:33:33 -07:00
Shubham Sandeep Rastogi
17e756ba81 Set debug location to Coroutine call expression
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.
2025-05-13 11:11:38 -07:00
Anthony Latsis
3596104550 Merge pull request #80987 from AnthonyLatsis/rebranch-fix
[rebranch] Get rebranch building with new LLVM stable branch
2025-04-25 13:08:24 +01:00
Anthony Latsis
124608b481 IRGen: Conservatively handle new HLSL clang::ParameterABI enum cases
Per 89fb8490a99e612f7a574e8678b21a90f689f5b4 (llvm-project).
2025-04-24 01:52:47 +01:00
Anthony Latsis
3eda91e511 ClangImporter, IRGen: Conservatively handle new clang::HLSLAttributedResourceType
Per e00e9a3f8294c9b96cb0328bf136fab72aeec749 (llvm-project).
2025-04-24 01:52:47 +01:00
Anthony Latsis
547a8910c2 AST, ClangImporter, IRGen: Conservatively handle new HLSL clang::BuiltinType::Kind enum case
Per 52956b0f705499ae4a268d3629b402ecdc2cbbab (llvm-project).
2025-04-24 01:52:46 +01:00
Anthony Latsis
f93aba0770 IRGen, LLVMPasses: Switch from obsoleted nocapture to captures(none)
Per 29441e4f5fa5f5c7709f7cf180815ba97f611297 (llvm-project).
2025-04-24 01:52:45 +01:00
Arnold Schwaighofer
3f8c743aed IRGen: Centralize logic that decides whether the platform suppports typed malloc
NFC intended
2025-04-23 10:43:06 -07:00
Arnold Schwaighofer
5762912af5 Merge pull request #80639 from aschwaighofer/store_once_async_context_addr
IRGen: Don't stored the current async frame to llvm.swift.async.context.addr twice
2025-04-17 08:23:22 -07:00
Andrew Trick
2d9df8ff78 Fix IRGen for @_addressable params which may be "captured".
Simply omit the 'nocapture' attribute on the parameter.

Fixes rdar://148039510 ([nonescapable] IRGen: lower addressable
params to LLVM: captures(ret: address, provenance))
2025-04-10 09:40:19 -07:00
Arnold Schwaighofer
0bb30d6ed3 Fix type continued 2025-04-09 07:26:41 -07:00
Rashmi Mudduluru
5e2f20b2d8 [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function (#79889)
* [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
2025-04-08 09:58:24 -07:00
Arnold Schwaighofer
50ebb3f579 IRGen: Don't stored the current async frame to llvm.swift.async.context.addr twice
rdar://148826951
2025-04-08 08:12:07 -07:00
Nate Chandler
24bb9bb738 [CoroutineAccessors] Adopt swiftcoro param attr. 2025-03-28 17:10:53 -07:00
Nate Chandler
b38d3eee58 [CoroutineAccessors] Use SwiftCC'd malloc/free.
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.
2025-03-27 19:23:09 -07:00
Nate Chandler
c141586838 [CoroutineAccessors] Open code dealloc fn. 2025-03-27 19:23:09 -07:00
Nate Chandler
dd238343bb [CoroutineAccessors] Open code alloc fn.
Replace the runtime function with an open-coded version.
2025-03-27 19:23:09 -07:00
nate-chandler
b878155a5a Merge pull request #80335 from nate-chandler/general-coro/20250326/2
[CoroutineAccessors] Move functions and add dealloc bit.
2025-03-27 19:19:25 -07:00
Dario Rexin
b7943bb849 Merge pull request #80287 from drexin/wip-147872231
[IRGen] Map result to native representation in emitAsyncReturn
2025-03-27 13:02:07 -07:00
Nate Chandler
2412ac3dc4 [CoroutineAccessors] Dedicate bit to dealloc time.
Don't rely on the kind for this.  Allow each allocator to decide for
itself for future compatibility.
2025-03-27 11:37:26 -07:00
Nate Chandler
dbcd038959 [CoroutineAccessors] Add wrapper for dealloc.
Make the fast path faster by avoiding a dyld stub.
2025-03-27 11:37:26 -07:00
Nate Chandler
0c2a38b10b [CoroutineAccessors] Directly reference allocators
Replace the call to a runtime function that looks up the allocator with
a direct reference to a just-emittedd sought-after global allocator.
2025-03-26 08:35:35 -07:00