Commit Graph

902 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
2cdbfa77bf [DefaultOverrides] IRGen. 2025-03-25 07:22:43 -07:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
nate-chandler
c0ba520fac Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2025-03-07 20:08:42 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Nate Chandler
d1f1b4c86b [CoroutineAccessors] Use swiftcorocc if available.
When it's available, use an open-coded allocator function that returns
an alloca without popping if the allocator is nullptr and otherwise
calls swift_coro_alloc.  When it's not available, use the malloc
allocator in the synchronous context.
2025-02-27 18:20:53 -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
fdd3eb0fce [IRGen] Define coroutine function pointer types.
They're isomorphic to async function pointers.  Even so, having this
distinction will be clearer than reusing AFPs for this other purpose.
2025-02-27 07:53:13 -08:00
Konrad `ktoso` Malawski
09003d6f11 Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d2604f.
2025-02-23 22:59:21 -08:00
Konrad `ktoso` Malawski
4ab5d2604f Merge pull request #77609 from ktoso/wip-task-names
[Concurrency] Task names
2025-02-21 22:28:33 +09:00
Saleem Abdulrasool
5770d59e4d Merge pull request #78427 from compnerd/internals
IRGen: special case VWT emission linkage computation
2025-01-25 08:51:06 -08:00
Saleem Abdulrasool
6df1c54c70 IRGen: remove unused method (NFCI)
This function is not used anywhere in the compiler or runtime, so remove
it.
2025-01-21 08:42:11 -08:00
Saleem Abdulrasool
59e7c1b538 IRGen: special case VWT emission linkage computation
The well known builtin and structural types are strongly defined in the
runtime which is compacted into the standard library. Given that the VWT
is defined in the runtime, it is not visible to the Swift compilation
process and as we do not provide a Swift definition, we would previously
compute the linkage as being module external (`dllimport` for shared
library builds). This formed incorrect references to these variables and
would require thunking to adjust the references.

One special case that we add here is the "any function" type
representation (`@escaping () -> ()`) as we do use the VWT for this type
in the standard library but do not consider it part of the well known
builtin or structural type enumeration.

These errors were previously being swallowed by the build system and
thus escaped from being fixed when the other cases of incorrect DLL
storage were.
2025-01-07 10:45:13 -08:00
Saleem Abdulrasool
ddfb26b1c6 Merge pull request #78226 from compnerd/standard-standards
IRGen: simplify the stdlib special casing for Windows
2024-12-18 14:35:01 -08:00
Saleem Abdulrasool
c052d1b935 IRGen: simplify the stdlib special casing for Windows
Remove `IRGenModule::useDllStorage()` as there is a standalone version
that is available and the necessary information is public from the
`IRGenModule` type. Additionally, avoid the wrapped `isStandardLibrary`
preferring to use the same method off of the public accessors. This
works towards removing some of the standard library special casing so
that it is possible to support both static and dynamic standard
libraries on Windows.
2024-12-16 14:46:38 -08:00
Egor Zhdan
57c7ecd244 [cxx-interop] Fix memory layout for structs with out-of-order base types
In C++, a primary base class that is placed in the beginning of the type's memory layout isn't always the type that is the first in the list of bases – the base types might be laid out in memory in a different order.

This makes sure that IRGen handles base types of C++ structs in the correct order.

This fixes an assertion in asserts-enabled compilers, and an out-of-memory error in asserts-disabled compilers. The issue was happening for both value types and foreign reference types. This change also includes a small refactoring to reuse the logic between the two code paths.

rdar://140848603
2024-12-16 15:53:43 +00:00
Arnold Schwaighofer
f9941b339a IRGen: Outlined value functions of types that might expand differently in
different TUs must use private linkage

rdar://136376117
2024-11-12 13:03:13 -08:00
swift-ci
ffb7eef5ab Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 05:15:25 -07:00
Arnold Schwaighofer
8ebb3ec473 IRGen: Add the ability to mark certain generic entry points in back traces
Mark generic function calls with concrete parameters, generic v-table calls and
generic witness table calls where self is generic.
2024-10-14 14:06:10 -07:00
Ben Barham
c15bc19946 Merge remote-tracking branch 'origin/main' into main-to-rebranch
Conflicts:
  - `lib/Serialization/ModuleFileSharedCore.cpp` new headers on main
2024-09-26 16:01:56 -07:00
eeckstein
8c5d7ee452 Merge pull request #76669 from eeckstein/class-existentials
embedded: support class existentials with generic classes
2024-09-26 07:37:35 +02:00
Doug Gregor
624570db57 Improve naming of the isResilientConformance flag that disables optimizations
Thank you, Arnold, for talking through this with me.
2024-09-25 13:05:22 -07:00
Doug Gregor
21b2f099de Use "resilient conformance" logic for deciding protocol dependencies involving Sendable
When compiling with library evolution and a pre-Swift 6.0 deployment
target, a mismatch between the notion of resilience used for determining
whether a protocol that inherits Sendable might need to be treated as
"dependent" differed from how other parts of IR generation decided
whether to conformance should be considered as resilient. The
difference came when both the protocol and its conforming type are in
the same module as the user.

Switch over to the "is this conformance resilient?" query that takes
into account such conformances.

Fixes rdar://136586922.
2024-09-25 12:09:40 -07:00
Joe Groff
4e3f665cc8 Merge pull request #76688 from jckarter/atomic-layout
IRGen: Set a "not bitwise borrowable" bit in value witnesses for `@_rawLayout` types.
2024-09-25 08:09:56 -10: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
Joe Groff
57a56e5804 IRGen: Set a "not bitwise borrowable" bit in value witnesses for @_rawLayout types.
For types like `Atomic` and `Mutex`, we want to know that even though they are
technically bitwise-takable, they differ from other bitwise-takable types until
this point because they are not also "bitwise-borrowable"; while borrowed,
they are pinned in memory, so they cannot be passed by value as a borrowed
parameter, unlike copyable bitwise-takable types. Add a bit to the value witness
table flags to record this.

Note that this patch does not include any accompanying runtime support for
propagating the flag into runtime-instantiated type metadata. There isn't yet
any runtime functionality that varies based on this flag, so that can
be implemented separately.

rdar://136396806
2024-09-24 19:08:50 -07:00
Ben Barham
a7b50f357f Merge remote-tracking branch 'origin/main' into manual-main-merge
Conflicts:
  - `lib/Driver/ToolChains.cpp` conflicting with the `addAllArgs` rename
    for multiple options
2024-09-16 13:53:18 -07: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
swift-ci
f1ea924a51 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-24 10:14:18 -07:00
Allan Shortlidge
bb8a837dcf IRGen: Honor -target-variant flag for zippered macCatalyst binaries. 2024-07-23 17:00:10 -07:00
swift-ci
0be42b6b18 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-11 06:14:58 -07:00
Slava Pestov
403bb98451 AST: Optimize collectLinkLibraries()
SourceFile::collectLinkLibraries() did not depend on the source file,
so let's move this logic up into ModuleDecl::collectLinkLibraries().
2024-07-10 23:06:22 -04:00
Ben Barham
8e9ac93bd3 [IRGen] Use ConstantInt for otherDiscriminator 2024-07-01 14:52:51 -07:00
Ben Barham
b7954411ec Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `include/swift/AST/PluginRegistry.h`
2024-06-27 14:56:11 -07:00
Alex Lorenz
af36238004 Merge pull request #74640 from hyp/eng/virtual-destructor-vtable-ref-irgen-linux-android
[cxx-interop] ensure that the body of implicit virtual destructor is …
2024-06-26 10:32:51 -07:00
Alex Lorenz
cd1ca50c63 [cxx-interop] ensure that the body of implicit virtual destructor is defined before emitting the clang decl for it
This ensures that the destructor definition is emitted into the module's LLVM IR, fixing a linker error.
2024-06-21 17:00:15 -07:00
swift-ci
b861f5c6f3 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-14 07:15:26 -07:00
Konrad `ktoso` Malawski
2ec717b115 [Concurrency] TaskExecutor ownership fixes (#74000) 2024-06-14 22:56:33 +09:00
swift-ci
50ff2bfca4 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-22 10:34:59 -07:00
Erik Eckstein
162139364e IRGen: support read-only statically initialized arrays in embedded swift
Arrays buffers need to be initialized with a (minimal) metatype and with an immortal reference count.
2024-05-21 18:04:10 +02:00
Ben Barham
17b34312df [IRGen] Start cleaning up typed pointers
Typed pointers are slowly being removed. There's a lot more cleanup to
do here, since really all `IRGenModule::.*PtrTy` should just be `PtrTy`,
but this at least gets us compiling for now.
2024-04-08 08:58:59 -07:00
John McCall
d8767b7724 Pass the task option record pointer to swift_task_create as a pointer.
We add the `memory(argmem: readwrite)` attribute to swift_task_create,
which means that the call is only allowed to read or write "pointer
operands".  LLVM is smart enough to look through obvious ptrtoint
casts, but not to look through integer selects and so on, which is what
we produce when there's an opaque optional operand that feeds into the
builtin.  This was causing miscompiles under optimization when using
`@isolated(any)` function types for task creation, since we're not yet
clever enough to fold the function_extract_isolation for a known function
(and of course it's not necessarily a known function anyway).
2024-03-15 00:40:54 -04:00
John McCall
0901b2b0b3 Add builtin support for starting a task on a specific executor.
This should be close enough to the creation of this builtin that we don't
need a new feature for it specifically.
2024-03-11 19:44:50 -04:00
Pavel Yaskevich
1e06448da7 [IRGen] Distributed: Remove a requirement that accessible function should be backed by SILFunction
Distributed protocol requirements don't have associated SILFunction,
let's introduce a more flexible way to define it that collects only
the information necessary for the function to become accessible.
2024-03-04 15:59:57 -08:00
Pavel Yaskevich
c6820a539b [IRGen] Distributed: Expand distributed actor accessor to support protocol requirements
Given the following protocol:

```
protocol Greeter : DistributedActor {
  distributed func greet()
}
```

The changes make it possible to synthesize a distributed accessor
thunk for the requirement `greet` which would be dispatched to the
underlying concrete actor implementation at runtime.
2024-03-04 15:59: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
Akira Hatanaka
b3f302b96b [IRGen] Fix a bug where an argument wasn't annotated with sret (#71459)
Fix a bug in expandExternalSignatureTypes where it wasn't annotating a function call parameter type with sret when the result was being returned indirectly.

The bug was causing calls to ObjC methods that return their results indirectly to crash.

Additionally, fix the return type for C++ constructors computed in expandExternalSignatureTypes. Previously, the return type was always void even on targets that require constructors to return this (e.g., Apple arm64), which was causing C++ constructor thunks to be emitted needlessly.

Resolves rdar://121618707
2024-02-22 14:14:47 -08:00
nate-chandler
4154cdb475 Merge pull request #71799 from nate-chandler/noncopyable-bugs/20240221/2
[IRGen] Outlined value functions that destroy move-only-with-deinit types take and forward those types' metadata.
2024-02-22 06:53:05 -08:00
Konrad `ktoso` Malawski
1d44e2e8e0 [Distributed] Undo new record and mangling scheme for dist.p.witnesses (#71801) 2024-02-22 23:02:29 +09:00