Commit Graph

252 Commits

Author SHA1 Message Date
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
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Nate Chandler
a50a3f022b [CoroutineAccessors] Mangling.
Change the suffix to Twc and demangle.
2025-03-07 11:40:38 -08:00
Nate Chandler
dd8cbe3e0a [CoroutineAccessors] Use retcon.once variant.
Allocate a coroutine frame in the caller based on the size in the
corresponding "function pointer" and pass it along with an allocator to
the callee.
2025-02-27 07:53:58 -08:00
Nate Chandler
3d655f58a2 [IRGen] Add coroutine fp link entities.
Duplicative boilerplate copying what was done for async function
pointers which these have the same characteristics as.
2025-02-27 07:53:13 -08:00
Kuba Mracek
b2f87e7614 [embedded] Add an experimental -Xfrontend -mergeable-symbols to allow linking multiple .o modules in Embedded Swift 2025-02-08 11:56:09 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Amritpan Kaur
6066418340 Merge pull request #73242 from amritpan/metatype-kp-implementation 2024-09-28 02:46:15 -07:00
Amritpan Kaur
2d70cd74e7 [IRGen] Weak link static keypath component property descriptors. 2024-09-25 12:54:52 -07:00
Erik Eckstein
2950e4521e SIL: representation for specialized witness tables
The main change here is to associate a witness table with a `ProtocolConformance` instead of a `RootProtocolConformance`.
A `ProtocolConformance` is the base class and can be a `RootProtocolConformance` or a `SpecializedProtocolConformance`.
2024-09-25 19:32:08 +02:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Konrad `ktoso` Malawski
eb675c222e [Distributed] Correct tbd handling for distributed thunks (#74935) 2024-07-26 16:52:18 +09:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Erik Eckstein
09d2e8f685 IRGen: add forceShared flag to LinkeEntity for type metadata 2024-05-21 18:04:10 +02:00
Pavel Yaskevich
89e4fb25d6 [IRGen] Distributed/NFC: Switch from ASTMangler to IRGenMangler 2024-03-04 15:59:57 -08:00
Pavel Yaskevich
0f41071fe6 [IRGen] Distributed: Switch DistributedAccessor linking to reference underlying thunks
Preparing to start emitting distributed requirement accessors
that don't have `SILFunction *` because they are associated with
protocol requirements.
2024-03-01 17:12:23 -08:00
Konrad `ktoso` Malawski
c56a1e8be7 [Distributed] Handle mangling thunks in extensions with generic AS and $Stubs (#71914) 2024-02-29 04:22:00 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Erik Eckstein
eaabcfd933 IRGen: restrict generation of read-only static objects to Array buffers
Currently only arrays can be put into a read-only data section.
"Regular" classes have dynamically initialized metadata, which needs to be stored into the isa field at runtime.
2024-01-10 09:33:17 +01:00
Cyndy Ishida
331b11f39c [TBDGen] Determine whether symbols belong in TEXT/DATA to record in tbd
files
2023-11-10 08:48:28 -08:00
swift-ci
d253b717d2 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-07 19:35:15 -07:00
Kuba Mracek
5d8c55eacb [embedded] Initial Swift Concurrency for embedded Swift 2023-10-06 20:04:03 -07:00
swift-ci
174b6bc00c Merge remote-tracking branch 'origin/main' into rebranch 2023-08-18 19:34:12 -07:00
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Slava Pestov
90562a0fe9 IRGen: Fix linkage of opaque type descriptor with @_alwaysEmitIntoClient owner decl 2023-08-18 12:12:50 -04:00
Slava Pestov
99d68ba14c IRGen: Some progress toward tuple conformances 2023-08-18 12:12:50 -04:00
swift-ci
73cf37d597 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-16 17:33:42 -07:00
Pavel Yaskevich
eee923bc42 [IRGen] [AST] NFC: Remove @runtimeMetadata related code and metadata records 2023-08-15 12:17:31 -07:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Saleem Abdulrasool
c8f88175d8 IRGen: attribute correct linkage to Windows DSO handle
Partially address the incorrect handling for the `#dsohandle` on
Windows.

We were previously emitting a local definition for this external
constant, and worse yet, not marking the definition for COMDAT.  It is
unclear what definition would win ultimately (implementation defined),
as we had a definition as well as the linker synthesized value. We can
change the SIL linkage for this type to `DefaultForDeclaration` which
will give it `available_externally` and default visibility and storage
which is closer to what we desire.  However, because we do not track the
LLVM variables and apply heuristics for lowering the
`SILGlobalVariable`, we would attribute it with imported DLL Storage.
This would then cause us to fail at link time (amusingly enough link.exe
will report a LNK1000).  Special case the variable and track that we are
targeting a windows environment in the `UniversalLinkageInfo` so that we
do not special case this on other platforms.

This also has the nice side effect of allowing us to remove the special
case in the TBD handling.

Fixes: #64741
2023-04-02 10:08:16 -07:00
Konrad `ktoso` Malawski
12d1ebc4e7 fix the linkage of async func ptr to distributed accessors 2023-02-06 18:39:58 +09:00
Pavel Yaskevich
bcaaa91a53 [IRGen] Linking: Get AccessibleFunction parent module directly 2022-12-20 09:45:01 -08:00
Pavel Yaskevich
59d6509d55 [IRGen] Make it possible to get address of accessible func record
Runtime metadata attributes need a pointer to a generator that
could be used to instantiate an attribute value.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
b8819373d9 [IRGen] RuntimeMetadata: Add linking record for runtime discoverable attrs
Utilize newly added `Ha` postfix mangling for the entry.
2022-12-20 09:45:01 -08:00
Allan Shortlidge
5c13523216 IRGen: Generate #_hasSymbol helpers for dynamic and @_dynamicReplacement(for:) functions.
Resolves rdar://103404707
2022-12-19 14:22:10 -05:00
Allan Shortlidge
ce2f37507d IRGen: Add #_hasSymbol support for async declarations.
Actor isolated methods are still not supported, though, because typechecking doesn't allow a partial application of those.

Resolves rdar://102094672
2022-11-08 09:45:29 -08:00
Allan Shortlidge
7f20380f0b IRGen: Generate #_hasSymbol query functions.
For each decl that needs a `#_hasSymbol()` query function, emit the corresponding helper function body during IRGen. Use `IRSymbolVisitor` to collect linkable symbols associated with the decl and return true from the helper function if the address of every associated symbol is non-null.

Resolves rdar://101884587
2022-11-04 11:19:29 -07:00
Becca Royal-Gordon
6143b8379f Generate IR for @_objcImpl stored properties
Only works for trivial types right now because features related to initialization and deinitialization are seriously busted.
2022-10-18 17:21:56 -07:00
Arnold Schwaighofer
d810b0f7e4 IRGen: Pass the elementType of pointers through to operations
In preparation for moving to llvm's opaque pointer representation
replace getPointerElementType and CreateCall/CreateLoad/Store uses that
dependent on the address operand's pointer element type.

This means an `Address` carries the element type and we use
`FunctionPointer` in more places or read the function type off the
`llvm::Function`.
2022-10-03 15:27:12 -07:00
Allan Shortlidge
40eb1422bb IRGen/SIL: Fix IR linkage computation for inlined function references from modules imported @_weakLinked.
Include the parent `ModuleDecl` when serializing a `SILFunction` so that it is available on deserialized functions even though the full `DeclContext` is not present. With the parent module always available we can reliably compute whether the `SILFunction` comes from a module that was imported `@_weakLinked`.

Serialize the `DeclContext` member of `SILFunction` so that it can be used to look up the module that a function belongs to in order to compute weak import status.

Resolves rdar://98521248
2022-08-19 09:56:45 -07:00
Allan Shortlidge
0df911c45b IRGen: Weakly link associated conformance descriptors when either the protocol or the associated requirement is weak.
Previously, only the associated requirement was considered when deciding whether to weakly link an associated conformance descriptor. This lead to unexpected strong linkage for some symbols, interfering with back deployment when integrating with some frameworks.

Resolves rdar://96974850
2022-07-15 17:32:31 -07:00
Pavel Yaskevich
7622885b49 [IRGen] NFC: Fix attribute name: @_alwaysInlineIntoClient -> @_alwaysEmitIntoClient 2022-07-13 10:14:00 -07:00
Pavel Yaskevich
bf1164f4b5 Merge pull request #60010 from xedin/rdar-82791712
[IRGen] Emit opaque type descriptors into client for `@_alwaysInlineI…
2022-07-12 15:34:50 -07:00
Pavel Yaskevich
76ab70c3a8 [IRGen] Emit opaque type descriptors into client for @_alwaysInlineIntoClient decls
If opaque result type has availability conditions and is associated with
an `@_alwaysInlineIntoClient` declaration, its metadata descriptor has to
be emitted into a client module because the body of the inlined function
depends on it for the runtime information about the underlying type.

Resolves: rdar://82791712
2022-07-12 11:36:38 -07:00
Nate Chandler
f454717c6e [IRGen] Look through opaque types for protocol witness table lazy access function.
When determining the linkage of protocol witness table lazy access
functions and their cache variables, look through opaque types to find
the underlying decls.

rdar://96194366
2022-07-11 15:21:38 -07:00
John McCall
175f74d38f Implement symbolic demangling for extended existential metadata
Fixes rdar://96268090.
2022-07-01 11:21:53 -04:00
Erik Eckstein
24d077e78b IRGen: re-enable generate static arrays in read-only data sections.
So far, static arrays had to be put into a writable section, because the isa pointer and the (immortal) ref count field were initialized dynamically at the first use of such an array.

But with a new runtime library, which exports the symbols for the (immortal) ref count field and the isa pointer, it's possible to put the whole array into a read-only section. I.e. make it a constant global.

rdar://94185998

This reverts the revert commit df353ff3c0.
Also, I added a frontend option to disable this optimization: `-disable-readonly-static-objects`
2022-06-21 18:30:42 +02:00
Erik Eckstein
df353ff3c0 Revert "IRGen: generate static arrays in read-only data sections."
This reverts commit aca0d8358b.

I need to fix a problem before this can actually land.
2022-06-17 20:32:32 +02:00
Erik Eckstein
aca0d8358b IRGen: generate static arrays in read-only data sections.
So far, static arrays had to be put into a writable section, because the isa pointer and the (immortal) ref count field were initialized dynamically at the first use of such an array.

But with a new runtime library, which exports the symbols for the (immortal) ref count field and the isa pointer, it's possible to put the whole array into a read-only section. I.e. make it a constant global.

rdar://94185998
2022-06-17 11:21:29 +02:00