Commit Graph

557 Commits

Author SHA1 Message Date
Max Desiatov
0c4e56174b Merge pull request #82399 from swiftlang/maxd/embedded-wasm-tests
These tests still require a manual `lit.py` invocation for Wasm, which will be added as a separate CMake target in a future PR.
2025-07-04 15:36:15 +01:00
Erik Eckstein
2b8c63dcd3 MandatoryPerformanceOptimizations: don't specialize vtables for thin class metatype instructions
Fixes a wrong compiler error for imported C++ classes with custom reference counting.
rdar://154947835
2025-07-03 16:21:21 +02:00
Max Desiatov
ca3d6bcdbf Restrict Wasm tests to wasip1 in lit.local.cfg 2025-07-01 15:40:05 +01:00
Max Desiatov
db33d703bd Use %module-target-triple in concurrency-simple.swift 2025-07-01 12:16:31 +01:00
Max Desiatov
48ea5f1eec Disable one more ARM-specific IR/SIL test on WASI 2025-07-01 11:43:43 +01:00
Max Desiatov
7a117df7b2 For now disable previously ARM-specific tests on WASI
The overall change should be only localized to executable tests for now.
2025-07-01 11:43:43 +01:00
Max Desiatov
3505257161 Update for more tests 2025-07-01 11:43:43 +01:00
Max Desiatov
27e5d5c551 Fix/xfail/disable remaining tests for embedded Wasm 2025-07-01 11:43:43 +01:00
Max Desiatov
b10da622e9 Add OS=wasi as supported to embedded/lit.local.cfg
There's a predefined list of supported platforms that WASI should be added now that it has an official Embedded Swift SDK.
2025-07-01 11:43:43 +01:00
Max Desiatov
ce162890cf Use OS=wasi in test/embedded/hello.swift 2025-07-01 11:43:43 +01:00
Max Desiatov
1efd278f24 Enable more tests for Embedded Wasm 2025-07-01 11:43:43 +01:00
Erik Eckstein
606f7693d4 MandatoryPerformanceOptimizations: don't de-virtualize a generic class method call to specialized method
This results in wrong argument/return calling conventions.
First, the method call must be specialized. Only then the call can be de-virtualized.
Usually, it's done in this order anyway, because the `class_method` instruction is located before the `apply`.
But when inlining functions, the order (in the worklist) can be the other way round.

Fixes a compiler crash.
rdar://154631438
2025-07-01 09:44:47 +02:00
Erik Eckstein
f83fb1b14a Optimizer: add FunctionWorklist and CrossFunctionValueWorklist
Originally, `FunctionWorklist` was a private utility in MandatoryPerformanceOptimizations.
Moved this to `Worklist.swift` to make it generally available.
Also, simplify the `pop()` function which changes the popping order - therefore some test changes were necessary.
2025-06-20 08:14:59 +02:00
Erik Eckstein
c02bc2d421 IRGen: add an option -min-valid-pointer-value to override the target's LeastValidPointerValue
The LeastValidPointerValue is hard-coded in the runtime.
Therefore this option is only available in embedded swift - which doesn't have a runtime.

rdar://151755654
2025-06-03 09:27:35 +02:00
Erik Eckstein
cf55b9bede MandatoryPerformanceOptimizations: make sure to handle de-serialized vtable methods
When de-serializing a function and this function allocates a class, the methods of the de-serialized vtable must be handled, too.

Fixes an IRGen crash
rdar://152311945
2025-06-02 11:43:34 +02:00
Kuba Mracek
544251bdc2 [embedded] Resolve a circular dependency problem in SwiftShims when using pico-libc 2025-05-29 17:37:32 -07:00
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