Commit Graph

541 Commits

Author SHA1 Message Date
Erik Eckstein
5ab8e40597 embedded: enable serialization of debug info in embedded mode
This is important to get diagnostics for errors which are located in imported modules.
Such errors can sometimes only be detected when building the client module, because the error can be in a generic function which is specialized in the client module.

rdar://151162353
2025-05-14 11:43:48 +02:00
Erik Eckstein
be322877b1 EmbeddedSwiftDiagnostics: improve error message for non-specialized generic function calls
Tell the user if the specialization isn't done because of a dynamic Self type.

rdar://150865684
2025-05-08 19:21:08 +02:00
Erik Eckstein
d9c7a68249 EmbeddedSwiftDiagnostics: fix a wrong "cannot use co-routines (like accessors) in -no-allocations mode" error
rdar://150890424
2025-05-08 19:21:08 +02:00
Kuba (Brecka) Mracek
217a09170c Merge pull request #81154 from kubamracek/embedded-ir-trap-test-require-no-asserts
[embedded] Require swift_stdlib_no_asserts in test/embedded/traps-fatalerror-ir.swift
2025-04-29 16:03:54 -07:00
Konrad 'ktoso' Malawski
6872707574 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:26 +09:00
Konrad 'ktoso' Malawski
e1dc854f8f [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-29 20:08:55 +09:00
Kuba Mracek
01a4b54f51 [embedded] Require swift_stdlib_no_asserts in test/embedded/traps-fatalerror-ir.swift 2025-04-28 17:27:02 -07:00
Kuba Mracek
c0ea02f86d [embedded] Add swift_allocEmptyBox to the embedded runtime 2025-04-21 15:47:34 -07:00
Kuba (Brecka) Mracek
1281f5910a Merge pull request #80682 from kubamracek/embedded-lossless-convertible
[embedded] Add back LosslessStringConvertible to Bool and integer types
2025-04-21 14:50:57 -07:00
Erik Eckstein
6c31eb0c43 embedded: rewrite the diagnostic pass for embedded swift
1. move embedded diagnostics out of the PerformanceDiagnostics pass. It was completely separated from the other logic in this pass, anyway.
2. rewrite it in swift
3. fix several bugs, that means: missed diagnostics, which led to IRGen crashes
  * look at all methods in witness tables, including base protocols and associated conformances
  * visit all functions in the call tree, including generic functions with class bound generic arguments
  * handle all instructions, e.g. concurrency builtins
4. improve error messages by adding meaningful call-site information. For example:
  * if the error is in a specialized function, report where the generic function is originally specialized with concrete types
  * if the error is in a protocol witness method, report where the existential is created
2025-04-18 06:58:40 +02:00
Erik Eckstein
d222cf20f1 MandatoryPerformanceOptimizations: support default methods for class existentials
For example:
```
protocol P: AnyObject {
  func foo()
}
extension P {
  func foo() {}
}
class C: P {}

let e: any P = C()
```

Such default methods are SILGen'd with a generic self argument. Therefore we need to specialize such witness methods, even if the conforming type is not generic.

rdar://145855851
2025-04-18 06:58:40 +02:00
Mike Ash
433ca8ea81 Merge pull request #80516 from mikeash/function-cast
[Runtime] Add function_cast, switch from std::bit_cast.
2025-04-11 05:15:25 -04:00
Mike Ash
185b739cf1 [Runtime] Add function_cast, switch from std::bit_cast.
Function types aren't always trivially copyable, e.g. with address-discriminated signed pointers on ARM64e. Introduce a function_cast helper and use that instead.
2025-04-10 20:29:02 -04:00
Kuba Mracek
a1c59d4140 [embedded] Annotate concurrency-modules.swift with REQUIRES: optimized_stdlib 2025-04-09 10:50:52 -07:00
Kuba Mracek
55f12fe13a [embedded] Add back LosslessStringConvertible to Bool and integer types 2025-04-09 10:08:58 -07:00
Kuba (Brecka) Mracek
edb25ce6e4 Merge pull request #80435 from kubamracek/embedded-reenable-dep-test
[embedded] Re-enable dependencies-random.swift test
2025-04-09 09:28:15 -07:00
Kuba (Brecka) Mracek
61f61c0e70 [embedded] Update 'REQUIRES' in dependencies-random.swift 2025-04-08 22:15:00 -07:00
Kuba Mracek
d64a6ca2d5 [embedded] Use %target-embedded-link substitution for embedded linking in lit tests 2025-04-08 12:57:56 -07:00
Kuba Mracek
dcb2636aa1 [embedded] Fix linux-rng-support.c compiling in C++ mode, make it C instead 2025-04-07 16:46:27 -07:00
Erik Eckstein
14ff3ea05f SILLinker: de-serialize Executor witness tables for the xExecutorRef builtins
Fixes unresolved symbol linker errors in embedded mode.
rdar://148538336
2025-04-04 14:32:48 +02:00
Erik Eckstein
e68882e8a3 SILLinker: make sure to de-serialize base protocol witness tables in embedded mode
Fixes unresolved symbol linker errors or compiler crashes
rdar://148538336
2025-04-04 14:32:48 +02:00
Artem Chikin
69b4ea3469 Merge pull request #80421 from swiftlang/revert-80246-playing-with-pointy-pointers
Revert "Concurrency: remove workaround for silencing UB"
2025-04-03 16:12:53 -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
Alastair Houghton
963edb794e Merge pull request #80410 from al45tair/eng/PR-148254407
[Tests][Embedded] Update dependencies for embedded concurrency slightly.
2025-04-01 16:27:52 +01:00
Kuba Mracek
35a1ce0999 [embedded] Re-enable dependencies-random.swift test 2025-04-01 06:42:36 -07:00
Kuba Mracek
c9ea28c3c7 [embedded] Make linux-rng-support.c friendly to compiling in both C and C++ mode 2025-04-01 06:32:18 -07:00
Konrad `ktoso` Malawski
240a43b054 Revert "Concurrency: remove workaround for silencing UB" 2025-04-01 07:09:57 +09:00
Kuba Mracek
6d71f45101 [embedded] Stop using -D__APPLE__ and -D__MACH__ 2025-03-31 15:07:11 -07:00
Kuba Mracek
461a25ce46 [embedded] Add %linux_rng_support_c_if_needed lit substitution 2025-03-31 14:35:30 -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
903472d2bc [Tests][Embedded] Update dependencies for embedded concurrency slightly.
We should allow `_memcpy`.

rdar://148254407
2025-03-31 17:34:49 +01:00
Saleem Abdulrasool
50e4cc78f6 Merge pull request #80246 from compnerd/playing-with-pointy-pointers
Concurrency: remove workaround for silencing UB
2025-03-28 18:34:27 -07:00
Mike Ash
ecdcb82b97 Merge pull request #80316 from mikeash/lock-record-begone
[Concurrency] Eliminate StatusRecordLockRecord.
2025-03-28 17:18:40 -04:00
Mike Ash
45727aff76 Fix concurrency-leaks.swift test to account for no more status lock record. 2025-03-28 09:59:33 -04:00
Saleem Abdulrasool
87f2b88ada Concurrency: remove workaround for silencing UB
The newer clang properly identifies UB on invalid pointer casts. This
was previously being silenced by suppressing the warnings. Adjust the
code to use `std::bit_cast` (or the shim implementation) to avoid the
UB in this code.
2025-03-27 08:27:06 -07:00
Kuba Mracek
a1cbb85b56 Fix REQUIRES lines in test/embedded/traps-mergeable.swift, include experimental features 2025-03-24 09:04:11 -07:00
Kuba Mracek
0318d2ba45 Adjust test/embedded/traps-mergeable.swift for $e mangling in Embedded Swift 2025-03-24 09:04:11 -07:00
Kuba Mracek
164b61c83d Add -Xfrontend -mergeable-traps as a way to emit mergeable traps 2025-03-24 09:04:11 -07:00
Kuba (Brecka) Mracek
033f6679e8 Merge pull request #80185 from kubamracek/embedded/used
[embedded] Link in @_used declarations from other modules in SILLinker
2025-03-22 12:01:56 -07:00
Kuba Mracek
9a293ed29a [embedded] Link in @_used declarations from other modules in SILLinker 2025-03-20 15:52:15 -07:00
Kuba (Brecka) Mracek
605f1c94cf Merge pull request #79892 from kubamracek/embedded/mergeable-weakodr
[embedded] Emit weak_odr instead of linkonce_odr symbols under -Xfrontend -mergeable-symbols
2025-03-20 10:27:13 -07:00
Kuba Mracek
7c9bc7c362 [embedded] Tweak REQUIRES clauses in linkage tests 2025-03-19 13:36:51 -07:00
Kuba Mracek
e860bbb12d [embedded][Concurrency] Add a test for a 'async throws(T)' typed throws async function 2025-03-19 11:17:29 -07:00
Konrad `ktoso` Malawski
a92f37998e [freestanding] prefer strncpy with known length (#80005) 2025-03-14 04:44:09 -07:00
Kuba Mracek
1931ef175d Add test/embedded/linkage-mergeable-dead-strip.swift test 2025-03-11 10:48:55 -07:00
Erik Eckstein
23b4c6fc34 embedded: fix specialization of associated conformance entries in witness tables
When creating a specialized witness table, we need to get the right specialized conformance.
In IRGen don't emit associated conformance witness table entries if the protocol is not a class protocol.
In this case the associated type can never be used to create an existential. Therefore such a witness table entry is never used at runtime in embedded swift.

Fixes a compiler crash

rdar://146448091
2025-03-11 11:33:10 +01:00
Konrad `ktoso` Malawski
e056c63c89 [Concurrency] Implement isIsolatingCurrentContext requirement and mode (#79788) 2025-03-11 09:48:38 +09:00
Kuba Mracek
d25f1fa86f [embedded] Emit weak_odr instead of linkonce_odr symbols under -Xfrontend -mergeable-symbols 2025-03-10 15:01:23 -07:00
Kuba (Brecka) Mracek
43919e8b8a Merge pull request #79706 from kubamracek/embedded-concurrency-deleted-method
[embedded][Concurrency] Fix missing swift_deletedAsyncMethodError
2025-03-10 12:27:00 -07:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00