Commit Graph

34 Commits

Author SHA1 Message Date
Max Desiatov
7ec0837778 Embedded WASI: fix concurrency-deleted-method.swift test
The test was crashing due to `swift_unreachable("custom executors not supported in embedded Swift")` line in `swift_task_enqueueImpl`, as the corresponding non-embedded codepath was relying on an unspecialized generic function `_swift_task_enqueueOnExecutor` defined in `Executor.swift`. Unspecialized generics are unavailable in Embedded Swift, and such `@silgen_name` function can't be specialized when used from concurrency runtime code written in C/C++. We can redefine this function for Embedded Swift as using a class-bound existential instead, and re-enable this codepath with a slightly different call that avoids the use of unavailable `swift_getObjectType` function from the non-embedded runtime.
2025-07-31 16:00:40 +01:00
Alastair Houghton
85bb057a59 [Embedded] Add swift_getDefaultExecutor() to the list of functions to link.
We need to link `swift_getDefaultExecutor`, which is used from the C++
code.

rdar://156701386
2025-07-30 13:41:04 +01:00
Max Desiatov
729173274c Add linkWitnessTable to SILModule, use in Link.cpp 2025-07-24 14:58:21 +01:00
Max Desiatov
a7e958e252 Link.cpp: load MainActor: Actor WT for Embedded Swift 2025-07-24 14:58:21 +01:00
Alastair Houghton
b554839c8e [Concurrency][Embedded] Add some extra Concurrency functions.
We need to explicitly link `swift_asyncMainDrainQueueImpl` and
`swift_createDefaultExecutors` since those two do not have Concurrency
hooks and so aren't linked automatically by the macro-processing code.
2025-07-24 14:58:21 +01:00
Alastair Houghton
5339dbf301 [Concurrency][Embedded] Make sure Embedded Swift links Impl functions.
Teach the Embedded Swift compiler to include the Impl functions for the
functions that provide Concurrency hooks.
2025-07-24 14:58:21 +01:00
Kuba Mracek
9a293ed29a [embedded] Link in @_used declarations from other modules in SILLinker 2025-03-20 15:52:15 -07:00
Saleem Abdulrasool
ec70054c93 IRGen: further generalise runtime function generation
This adjusts the runtime function declaration handling to track the
owning module for the well known functions. This allows us to ensure
that we are able to properly identify if the symbol should be imported
or not when building the shared libraries. This will require a
subsequent tweak to allow for checking for static library linkage to
ensure that we do not mark the symbol as DLLImport when doing static
linking.
2025-01-15 13:54:34 -08:00
Erik Eckstein
67b8c08ef1 SILLinker: convert an assert to a compiler error message
Having a wrong linkage can happen if the user "re-defines" an existing function with a wrong linkage, e.g. using `@_cdecl`.
2025-01-08 11:00:27 +01:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Alex Hoppen
c5aa49ba64 Revert "Isolated synchronous deinit" 2024-09-03 18:11:26 -07:00
Mykola Pokhylets
9a0df5bcbf Don't add swift_retainCount() to RuntimeFunctions.def, but explicitly link it in linkEmbeddedRuntimeFromStdlib() 2024-08-21 14:53:09 +02:00
Erik Eckstein
4017501a4c re-instate: embedded: allow dead function elimination for de-serialized functions
This re-instates commit cc9e53bb08 with a fix for LLDB (rdar://124228107)

rdar://123772098
2024-03-11 15:38:00 +01:00
Michael Buch
8957f8186a Revert "embedded: allow dead function elimination for de-serialized functions" 2024-03-07 16:48:04 +00:00
Erik Eckstein
cc9e53bb08 embedded: allow dead function elimination for de-serialized functions
In embedded swift all de-serialized get public linkage because all the code is generated in the top-level module.
This change moves the point where we make de-serialized functions public to the end of the pipeline.
This allows dead function elimination to remove unused de-serialized functions.
For some stdlib functions (actually one: the Double initializer for a builtin integer) is essential, because codegen for embedded produces an unresolved symbol.

rdar://123772098
2024-03-06 20:51:09 +01:00
Kuba Mracek
23d6ee7f54 [embedded] Use ArrayRef<RuntimeEffect> as an argument 2024-01-04 13:30:30 +01:00
Kuba Mracek
2c24c1216f [embedded] In -no-allocations, avoid linking allocating/deallocating runtime functions 2024-01-04 13:28:56 +01:00
Kuba Mracek
bb1ba7c95c [embedded] Run DeadFunctionAndGlobalElimination after MandatoryPerformanceOptimizations 2023-12-09 22:39:55 -08:00
swift-ci
2e6b1cd2f7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 07:13:53 -07:00
Kuba Mracek
7c5962b8a7 [embedded] Prefer Module.getOptions().EmbeddedSwift in SIL code 2023-09-27 09:04:02 -07:00
Evan Wilde
dfab77eb8e Include memory effects in SILOptimizer/Link.cpp
Link.cpp started pulling in the macros from RuntimeFunctions.def, which
do not include memory effects on main, but do on rebranch. This resulted
in build failures due to extra parameters to the macro function.
2023-09-26 16:17:50 -07:00
Kuba Mracek
a835c6ba1f [embedded] -O and -Osize embedded runtime 2023-09-25 21:28:37 -07:00
Kuba Mracek
86ad378928 [embedded] Add a simple Swift runtime, written in embedded Swift 2023-09-25 19:51:19 -07:00
Slava Pestov
8c0f20987c SILOptimizer: Add 'mandatory SIL linker' pass
As a first step to getting mandatory inlining out of the business
of 'linking' (walking the function graph and deserializing all
referenced functions), add a new optimizer pass which links
everything in the mandatory pipeline.

For now this is mostly NFC, except it regresses an optimization
I made recently by linking in bodies of methods of deserialized
vtables eagerly. This will be addressed in upcoming patches.
2018-04-16 16:18:49 -07:00
Andrew Trick
39de8c7aed Revert "Mandatory SIL linker pass" 2018-04-14 16:41:34 -07:00
Slava Pestov
d520d030f5 SILOptimizer: Add 'mandatory SIL linker' pass
As a first step to getting mandatory inlining out of the business
of 'linking' (walking the function graph and deserializing all
referenced functions), add a new optimizer pass which links
everything in the mandatory pipeline.

For now this is mostly NFC, except it regresses an optimization
I made recently by linking in bodies of methods of deserialized
vtables eagerly. This will be addressed in upcoming patches.
2018-04-13 14:18:53 -07:00
Slava Pestov
81cf1d951d SIL: Remove -sil-link-all frontend flag
It was only used in a few tests. Those tests now use -emit-sil instead
of -emit-silgen, with some functions marked @_transparent and a few
CHECK: lines changed now that the mandatory optimizations get to run.
2018-04-09 13:27:52 -07:00
Slava Pestov
cc586594d1 SIL: Remove unnecessary performSILLinking() calls from immediate mode and REPL 2018-04-09 13:27:07 -07:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Erik Eckstein
a0079ba5be SIL optimizations: Implement the new API for analysis invalidation.
There are now separate functions for function addition and deletion instead of InvalidationKind::Function.
Also, there is a new function for witness/vtable invalidations.

rdar://problem/29311657
2017-03-14 13:00:54 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00