Commit Graph

12796 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
0a2989ab5c [Distributed] pointer auth protocol pointers as we use conformsToProtocol 2025-05-09 11:16:00 +09:00
Dario Rexin
7502c75806 [IRGen] Emit llvm fneg operation for Builtin.fneg_*
rdar://150722907

The original handling was a workaround before LLVM added the fneg operation. Now that it has it, we should use it.
2025-05-08 13:52:07 -07:00
Konrad `ktoso` Malawski
f6a864a188 Merge pull request #81135 from ktoso/pick-22b20e731eaa70746d3c21bf8c44836aa49dfabb
[6.2][Concurrency] Change isIsolatingCurrent... to return Bool?
2025-05-02 07:53:12 +09:00
Meghana Gupta
cc72edb119 Introduce end_cow_mutation_addr instruction 2025-04-30 14:38:48 -07:00
Konrad 'ktoso' Malawski
eaf0b15ea3 [Concurrency] Change isIsolatingCurrent... to return Bool?
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
2025-04-28 19:17:58 +09:00
Gabor Horvath
291a63fd80 [6.2][cxx-interop] Fix a crash with [[no_unique_address]]
Explanation: Swift does not support storing fields in the padding of the previous
fields just yet, so let's not import fields like that from C++.
Represent them as opaque blobs instead.
Issue: rdar://149072458
Risk: Low, the fix is targeted at a scenario that was crashing before.
Testing: Regression test added.
Original PR: #80786
Reviewer:
2025-04-25 12:51:13 +01:00
Arnold Schwaighofer
345d1a64c9 [6.2] LoadableByAddress: Fix shouldTransformYields to use (properly) substituted
types

Scope: The LoadableByAddress pass fails on some Swift source because it
ignores pattern substitutions.

Risk: Low. Many source patterns where this difference matters should have
crashed.

Fix: Don't ignore pattern substitutions.

Testing: The project that crashed no longer does. Unit test added.

rdar://149281263
issues/80818

(cherry picked from commit 521fb07523)
2025-04-22 08:16:52 -07:00
Arnold Schwaighofer
9775681216 Merge pull request #80907 from aschwaighofer/large_types_reg2mem_unchecked_bitwise_cast_propagate_6.2
[6.2] LargeTypesReg2Mem: Add unchecked_bitwise_cast to the projections we need to propagate largeness from destination to source operand
2025-04-22 07:31:49 -07:00
Konrad 'ktoso' Malawski
694af3317a [Distributed] Distributed actor usage through protocol with lib-evo must work
This corrects how we were dealing with dispatch thunks -- mostly be
removing a lot of special casing we did but doesn't seem necessary and
instead we correct and emit all the necessary information int TBD.

This builds on  https://github.com/swiftlang/swift/pull/74935 by further refining how we fixed that issue, and adds more regression tests. It also removes a load of special casing of distributed thunks in library evolution mode, which is great.

Resolves and adds regression test for for rdar://145292018

This is also a more proper fix to the previously resolved but in a not-great-way which caused other issues:
- resolves rdar://128284016
- resolves rdar://128310903

Review followup, cleanup test
2025-04-21 20:33:22 +09:00
Arnold Schwaighofer
e3133f736a [6.2] LargeTypesReg2Mem: Add unchecked_bitwise_cast to the projections we need to propagate largeness from destination to source operand
Scope: Fixes a compiler crash in some version of swift-collections
Issue: An instruction whose result type address'ness needs to be
propagated to its operand was not handled.
Risk: Low, this case would have crashed without the change.
Testing: Unit test added. The compiler successfully compiled the project
after this change.
Original PR: https://github.com/swiftlang/swift/pull/80888

rdar://148545382
(cherry picked from commit 370b7e8219)
2025-04-18 07:23:52 -07:00
John Hui
d7b44f4e94 Merge pull request #80718 from j-hui/fix-interop-private-debug-symbols-6.2 2025-04-15 17:08:18 -07:00
Rashmi Mudduluru
942eddf01e [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function (#79889) (#80769)
* [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
(cherry picked from commit 5e2f20b2d8)
2025-04-15 16:45:41 -07:00
Andrew Trick
097dba34ff Merge pull request #80709 from atrick/62-irgen-addressable
[6.2] Fix IRGen for @_addressable params which may be "captured".
2025-04-11 18:03:01 -07:00
Slava Pestov
b0b4a646f6 Merge pull request #80676 from slavapestov/fix-rdar148698142-6.2
[6.2] IRGen: Fix silly mistake in MetadataPath::followComponent()
2025-04-10 14:59:44 -04:00
Andrew Trick
e048dd1cf1 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))

(cherry picked from commit 2d9df8ff78)
2025-04-10 09:43:13 -07:00
John Hui
bafcb9dcca [cxx-interop] Do not get private discriminator for private Clang types (#80485)
When generating debug symbols for private Clang types (which we started
importing recently), the compiler crashes due to an assertion failure
from ClangModuleUnit::getDiscriminatorForPrivateDecl(), which is called
by getFilePrivateScope().

This patch fixes the issue crash by not calling getFilePrivateScope()
for Clang types. A discriminator is usually needed to disambiguate
private Swift types declared in different files, but Clang types follow
different scoping conventions that make this discriminator unnecessary.

rdar://148481025
(cherry picked from commit dd2f465025)
2025-04-10 06:54:58 -07:00
Adrian Prantl
95e7092889 [IRGenSIL] Factor out shouldUseDispatchThunk() (NFC)
(cherry picked from commit c4f073d39a)
2025-04-09 14:30:50 -07:00
Adrian Prantl
b2e24a9433 [IRGen] Improve legibility of conditional (NFC)
(cherry picked from commit 5a36f3baac)
2025-04-09 14:30:50 -07:00
Adrian Prantl
0231a3881b [LLDB] Fix conditional to also support AccessLevel::Open
This fixes crashes in LLDB expression evaluation when calling virtual
Open functions.

rdar://147797657
(cherry picked from commit f4a0f4b339)
2025-04-09 14:30:50 -07:00
Slava Pestov
cca31be781 IRGen: Convert null pointer derefs into unconditional asserts 2025-04-09 11:54:20 -04:00
Slava Pestov
f8bf194ece IRGen: Fix silly mistake in MetadataPath::followComponent()
This fixes a regression from a00157ec43.

My change made it so that sourceKey.Kind was checked after being
overwritten with an abstract conformance, so we would never take
the if statement. Incredibly, it almost worked.

Fixes rdar://problem/148698142.
2025-04-09 11:54:19 -04:00
Konrad `ktoso` Malawski
99ff7880ae Merge pull request #80574 from ktoso/wip-pickwip-tapi-validation
[6.2][Distributed] Fix distributed accessors for resilient modules
2025-04-09 08:31:35 +09:00
Nate Chandler
926bad2543 [IRGen] Fix type of deleted coro error func.
It was previously erroneously an async function pointer.  Also fix the
name.
2025-04-07 11:43:13 -07:00
Konrad 'ktoso' Malawski
df76286fba [Distributed] Dont emit TBD also for distributed thunks
This resolves pedantic "all" TBD validation issues, i.e. we dont emit
unexpected records anymore - we would before as we only checked for
is_distributed but we also want to skip those for is_distributed_thunk

resolves rdar://128284016
2025-04-07 13:19:01 +09:00
Konrad 'ktoso' Malawski
139d878940 [Distributed] Accessor must be available cross module in resilient mode
This is an important fix for libraries using @Resolvable in resilient
libraries. Without the fix we're missing an accessor and this will fail
some remote calls which make use of remote calls on resolvable
protocols. This would manifest as missing accessor error thrown by the
executeDistributedTarget function.

resolves rdar://148224780
2025-04-07 13:19:00 +09:00
Nate Chandler
63a1bb0705 [CoroutineAccessors] Use async bit in descriptors.
To facilitate back deployment, make use of the fact that the async bit
has up to now never been set for read and modify accessors and claim
that set bit to indicate that it is a callee-allocated coroutine.  This
has the virtue of being completely back deployable because like async
function pointers coro function pointers must be auth'd and signed as
data.
2025-04-04 15:50:11 -07:00
nate-chandler
0e2ca9a07d Merge pull request #80483 from nate-chandler/general-coro/20250327/2
[CoroutineAccessors] Open-code a task_dealloc_thru
2025-04-03 21:21:06 -07:00
Augusto Noronha
cac0abbfde Merge pull request #80380 from augusto2112/fix-opaque
[DebugInfo] Use underlying type of global variables with opaque type
2025-04-03 15:39:11 -07:00
Nate Chandler
cb68533649 [CoroutineAccessors] Open-code a task_dealloc_thru
When building for back-deployment, emit calls to an open-coded
`_swift_task_dealloc_through` function rather than the runtime
`swift_task_dealloc_through` which doesn't exist on them.
2025-04-03 13:45:27 -07:00
Kuba (Brecka) Mracek
eb1c92575d Merge pull request #80416 from kubamracek/embedded-mergeable-global-refs
[embedded] Fix compilation crash with -num-threads and -mergeable-symbols
2025-04-03 08:49:26 -07:00
Augusto Noronha
6abbc0d754 [DebugInfo] Use underlying type of global variables with opaque type
rdar://144881938
2025-03-31 15:52:09 -07:00
Nate Chandler
41fa97f62d [IRGen] Add convenience to define transient types.
Expose the createStructType helper to clients of IRGenModule which want
to define types which won't ever be used elsewhere.  This is just a
convenience--such clients could already have directly used the API on
llvm::Module directly.
2025-03-31 13:48:39 -07:00
Nate Chandler
f7540284b0 [NFC] IRGen: Fix field of task.
It doesn't have a status after the resume context.
2025-03-31 13:47:13 -07:00
Kuba Mracek
e80cc2fb34 [embedded] Fix compilation crash with -num-threads and -mergeable-symbols 2025-03-31 11:23:50 -07:00
Alastair Houghton
b1c345f1be Merge pull request #80266 from al45tair/custom-executors-take2
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-31 09:53:48 +01:00
Steven Wu
e132e1c0f3 Merge pull request #80370 from cachemeifyoucan/eng/PR-147971980
[IRGen] Fix non-deterministic requests in addAbstractForFulfillments()
2025-03-29 21:07:02 -07:00
Nate Chandler
24bb9bb738 [CoroutineAccessors] Adopt swiftcoro param attr. 2025-03-28 17:10:53 -07:00
nate-chandler
b8c97b9836 Merge pull request #80361 from nate-chandler/general-coro/20250327/1
[CoroutineAccessors] Open code alloc/dealloc functions.
2025-03-28 13:20:01 -07:00
Steven Wu
cdf881f559 [IRGen] Fix non-deterministic requests in addAbstractForFulfillments()
In `addAbstractForFulfillments()`, FulfillmentMap (DenseMap) is
iterated to compute all the cache entries. Even the
non-deterministic iteration order doesn't affect the computed cache
entries, the requests to the evaluator during the process will be in
non-deterministic order. This will cause the fine-grain dependency file
generated to be non-deterministic. Use a `MapVector` to make sure
iteration order is deterministic.

rdar://147971980
2025-03-28 09:37:43 -07:00
Egor Zhdan
63c24afde6 Merge pull request #80344 from swiftlang/egorzhdan/frt-tail-padding
[cxx-interop] Layout reference types that use tail padding of their bases correctly
2025-03-28 12:26:01 +00:00
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Dario Rexin
76171bd109 Merge pull request #80353 from drexin/wip-142485229
[IRGen] Don't store payload in destructiveInjectEnumTag when payload …
2025-03-27 23:46:39 -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
191749651b [CoroutineAccessors] Fall back to DefaultCC.
The fallback should be DefaultCC which is not necessarily SwiftCC.
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
f984f94866 [IRGen] Don't store payload in destructiveInjectEnumTag when payload is empty type
rdar://142485229

In generic multi payload enums, if the payload was empty, we missed a check for that when storing the payload and always cleared out the extra tag byte.
2025-03-27 14:58:45 -07:00
Doug Gregor
a61c40054d Merge pull request #80337 from DougGregor/cast-prohibits-isolated-conformances
[SE-0470] Prohibit isolated conformances in dynamic casts that can't safely use them
2025-03-27 14:17:45 -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