Commit Graph

328 Commits

Author SHA1 Message Date
Arnold Schwaighofer
a725de5ba6 Address review comments 2025-11-17 15:52:00 -08:00
Arnold Schwaighofer
4285a2169d IRGen: Start support for embedded existentials
Allow storing struct, enum, and tuple types in an any.
2025-11-17 12:46:35 -08:00
Slava Pestov
41ff7383d9 IRGen: Clean up opaque type specialization wrappers 2025-10-23 15:36:54 -04:00
Michael Gottesman
2fa3908e94 [concurrency] Add a new type Builtin.ImplicitActor.
This is currently not wired up to anything. I am going to wire it up in
subsequent commits.

The reason why we are introducing this new Builtin type is to represent that we
are going to start stealing bits from the protocol witness table pointer of the
Optional<any Actor> that this type is bitwise compatible with. The type will
ensure that this value is only used in places where we know that it will be
properly masked out giving us certainty that this value will not be used in any
manner without it first being bit cleared and transformed back to Optional<any
Actor>.
2025-10-16 10:51:13 -07:00
Alejandro Alonso
89052a729a Merge pull request #84655 from Azoy/negative-nancy
[IRGen] Correctly sext instead of zext for negative integer types
2025-10-04 09:18:03 -07:00
Nate Chandler
8332b7c03f [VariadicGenerics] Fix memeffect of metadata accessor call.
Follow up to https://github.com/swiftlang/swift/pull/84635/.

The metadata accessor for a variadic generic type takes as arguments
packs of metadata records and witness tables, and each such pack is
passed in a buffer. So the call to any such accessor is not correctly
annotated memory(none).

rdar://161606892
2025-10-03 09:13:42 -07:00
Alejandro Alonso
bb5dfd317c Always use sext 2025-10-02 11:18:56 -07:00
Alejandro Alonso
2b00d3f123 Correctly sext instead of zext for negative integer types 2025-10-02 10:27:44 -07:00
John McCall
64d020ec45 [NFC] Introduce a convenience specialization of CanTypeVisitor that
forwards the paired nominal type methods to common implementations.
2025-09-05 14:02:36 -04:00
Anthony Latsis
f8577a2731 IRGen: Address llvm::Type::getPointerTo deprecation
See https://github.com/llvm/llvm-project/pull/113331.
2025-07-21 12:37:15 +01:00
Alejandro Alonso
c165509147 Correctly emit inverse proto comps with extended shape symbolic refs 2025-04-30 13:43:01 -07:00
Slava Pestov
9148ae32bd Merge pull request #80482 from slavapestov/abstract-conformance-cleanup
AST: Simplify ProtocolConformanceRef operations a little bit
2025-04-04 10:37:49 -04:00
Slava Pestov
a06a4213ef AST: Remove origType parameter from substOpaqueTypesWithUnderlyingTypes() 2025-04-03 17:35:34 -04:00
Augusto Noronha
6abbc0d754 [DebugInfo] Use underlying type of global variables with opaque type
rdar://144881938
2025-03-31 15:52:09 -07:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Saleem Abdulrasool
c7429f00c3 Merge pull request #79448 from compnerd/addressability
IRGen: adjust addressability of the generic metadata
2025-02-26 08:42:19 -08:00
Pavel Yaskevich
1067ead82c [Mangling] Mangle presence of @execution(caller) in a function type
If `@execution(caller)` attribute is present on a function type,
mark its presence in the mangling with `YC` suffix.
2025-02-19 16:48:41 -08:00
Saleem Abdulrasool
c0b612c6b0 IRGen: adjust addressability of the generic metadata
When building on Windows, if the nominal base type is in a non-static
library, we cannot reference the type descriptor directly. As a load is
required, we cannot statically initialise the pattern metadata. Account
for this in the addressability computation.
2025-02-17 15:03:50 -08:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00: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
John McCall
12bdfbf589 Fix a pair of IRGen bugs around materializing function type metadata
with sending results:

- The sending result mangling was added in the 6.0 runtime, so demangling
  cannot be used to produce this metadata when targeting an earlier
  runtime.

- The combination of a sending result with isolation requires the 6.1
  runtime to successfully demangle, due to a bug in the 6.0 demangler.
2025-01-23 02:24:51 -05: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
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
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Slava Pestov
5190d98e1b Merge pull request #77178 from slavapestov/misc-solver-cleanups
Miscellaneous solver cleanups
2024-10-24 16:52:01 -04:00
Slava Pestov
5e1e18424b AST: Clean up ExistentialLayout for ParameterizedProtocolType 2024-10-22 20:14:44 -04:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -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
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Slava Pestov
cf784f980e AST: Remove SubstFlags::AllowLoweredTypes 2024-08-23 13:14:05 -04:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Kuba Mracek
bda0c904ef [embedded] Fix crash when using failable initializers on generic classes 2024-06-24 20:36:02 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Egor Zhdan
dbe1a982d9 Merge pull request #74208 from apple/egorzhdan/frt-duplicate-metadata-accessor
[cxx-interop][IRGen] Emit type metadata accessors correctly
2024-06-07 22:49:23 +01:00
Egor Zhdan
a5ce0dc81d [cxx-interop][IRGen] Emit type metadata accessors correctly
This change makes sure we correctly emit IR for type metadata accessors for C++ reference types.

This fixes linker errors when a type metadata of a C++ reference type is used in multiple object files that are later linked together, for instance, if a C++ reference type is conformed to different Swift protocols in different Swift source files:
```
duplicate symbol 'type metadata accessor for __C.SharedObject' in:
  main.o
  second.o
ld: 1 duplicate symbols
```

rdar://129027705
2024-06-07 19:00:16 +01: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
Pavel Yaskevich
552749e2f3 [IRGen] Strip marker protocols when forming generic metadata requests
Without this might might end up with a single element protocol compositions
which are invalid.
2024-06-04 14:28:14 -07:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Slava Pestov
153da37521 IRGen: Use getMaximalTypeExpansionContext() 2024-04-04 19:36:25 -04:00
Slava Pestov
cbf4dce068 IRGen: Clean up substOpaqueTypesWithUnderlyingTypes() wrappers 2024-04-04 19:36:25 -04:00
Doug Gregor
b84f8ab080 Rename "suppressible protocols" to "invertible protocols".
We've decided to use the "invertible protocols" terminology throughout
the runtime and compiler, so move over to that terminology
consistently.
2024-03-29 11:31:48 -07:00
Doug Gregor
11774e5d17 [Runtime] Check function types against suppressible protocols
Form a set of suppressed protocols for a function type based on
the extended flags (where future compilers can start recording
suppressible protocols) and the existing "noescape" bit. Compare
that against the "ignored" suppressible protocol requirements, as we
do for other types.

This involves a behavior change if any client has managed to evade the
static checking for noescape function types, but it's unlikely that
existing code has done so (and it was unsafe anyway).
2024-03-22 07:45:50 -07:00
Erik Eckstein
3c76464c1c rename withConcurrent -> withSendable
That was missed when "concurrent" was renamed to "sendable"
2024-03-13 09:58:31 +01:00
John McCall
0f076c0702 Fix metadata availability testing for parameterized existentials
and implement it for @isolated(any) function types.

The existing testing was pretty broken: we were diagnosing all sorts
of things that don't require type metadata (like using a tuple with
an extended existential in a value position in an API signature)
and not diagnosing several things that do (like covariant function
conversions that erase types).  There's therefore some risk to this
patch, but I'm not too worried because needing metadata like this is
pretty uncommon, and it's likely that programs won't build correctly
anyway --- it'll just get caught by the linker instead of the compiler.
2024-02-29 22:14:49 -05:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Joe Groff
b9f91144d1 Fix ABI breakage caused by ValueOwnership order change.
The `ABI` headers had accidentally grown an `#include` into compiler headers,
allowing the enum constant values of the `ValueOwnership` enum to leak into
the runtime ABI. Sever this inappropriate relationship by declaring a separate
`ParameterOwnership` enum with ABI-stable values in the ABI headers, and
explicitly converting between the AST and ABI representation where needed.
Fixes rdar://122435628.
2024-02-20 07:55:16 -08:00