Commit Graph

12816 Commits

Author SHA1 Message Date
Augusto Noronha
bceb8176dd Fix miscompilations for debugger because of resilience
This patch fixes two instances of the compiler embedded in LLDB
miscompiling code for expression evaluation, because of a combination of
the debugger's access to private types and resilience, which would cause
the generated code to access fields indirectly through resilience functions
that were never emitted.

rdar://137876089
2025-01-17 15:50:09 -08:00
Augusto Noronha
aa6b5c2b63 [DebugInfo] Fix recursively generating debug info for same type
Debug Info generation already has a check to stop it from generating
debug info for a type with the same mangled name. However, most of the
code paths in debug info generation would not add the mangled name to
the cache while generation was not done. This patch fixes that so types
that are in-flight don't have their debug info generated twice.

rdar://142500619
2025-01-17 15:00:03 -08:00
Dario Rexin
30e7ba13b2 [IRGen] Add indirect typed error slot when async function has indirect result
rdar://142918657

Erorrs have to be passed indirectly whenever the result type is indirect.
2025-01-16 15:29:13 -08:00
Saleem Abdulrasool
0e77477147 Merge pull request #78553 from compnerd/well-known-imports
IRGen: further generalise runtime function generation
2025-01-16 09:25:54 -08:00
Arnold Schwaighofer
29bcd2caa0 Merge pull request #78445 from aschwaighofer/loadable_by_address_magic_constant
LoadableByAddress: Replace some magic constants
2025-01-15 15:53:13 -08: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
Egor Zhdan
18be5e862d Merge pull request #78467 from swiftlang/egorzhdan/sizeof-incomplete
[cxx-interop] Skip type metadata for C++ types that are only used in private C++ fields
2025-01-13 16:58:08 +00:00
Saleem Abdulrasool
0cdcfad408 Merge pull request #78583 from compnerd/fallthrough
IRGen: adjust code for MSVC warning C4468 (NFCI)
2025-01-13 07:47:45 -08:00
Egor Zhdan
738c8fb6c6 [cxx-interop] Skip type metadata for C++ types that are only used in private C++ fields
This fixes compiler errors for C++ types that use pimpl idiom:
```
invalid application of 'sizeof' to an incomplete type
```

rdar://141960396
2025-01-13 12:03:35 +00:00
Alejandro Alonso
09d122af7c Merge pull request #76438 from Azoy/vector
[stdlib] Slab
2025-01-12 10:36:25 -08:00
Saleem Abdulrasool
e37ffad1a6 IRGen: adjust code for MSVC warning C4468 (NFCI)
```
The [[fallthrough]] attribute must be followed by a `case` label or a
`default` label.
```

Restructure the code so that the `[[fallthrough]]` attribute is followed
by the subsequent `case` label for the `switch` statement.
2025-01-11 10:55:21 -08:00
Arnold Schwaighofer
7aef2b549c Fix static variable initializations 2025-01-09 11:42:04 -08:00
finagolfin
f67b35c2f2 Merge pull request #77883 from finagolfin/droid
[android] Use emulated thread-local storage for API 28 and earlier
2025-01-09 15:04:17 +05:30
Alejandro Alonso
515c64fd55 Use current insertion block as other incoming phi for each array element 2025-01-08 10:37:17 -08:00
Alejandro Alonso
08ce821442 If the element type of a B.FA is empty, set its storage type in LLVM to just the padding 2025-01-08 10:37:16 -08:00
Alejandro Alonso
445824dda0 Don't emit builtin metadata in the stdlib if it's generic 2025-01-08 10:37:16 -08:00
Alejandro Alonso
6ffaf4befc Don't ask for TypeInfo of IntegerType when generating debug info for generic args 2025-01-08 10:37:13 -08:00
Allan Shortlidge
d4d9c9e70a TBDGen: Adopt SemanticAvailableAttr. 2025-01-08 08:17:27 -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
Dario Rexin
0aebbeada8 [IRGen] Fix SignatureExpansion::expandAsyncReturnType()
rdar://141962253

This fixes an issue that caused parameters to be dropped when a typed error in an async closure was too big to be returned directly.
2025-01-06 12:21:51 -08:00
Arnold Schwaighofer
abbe36a1e9 LoadableByAddress: Replace some magic constants
NFC intended. Although there is a little fix in setNumRegisters.
2025-01-06 11:57:37 -08:00
Allan Shortlidge
d0f63a0753 AST: Split Availability.h into multiple headers.
Put AvailabilityRange into its own header with very few dependencies so that it
can be included freely in other headers that need to use it as a complete type.

NFC.
2025-01-03 18:36:04 -08:00
Arnold Schwaighofer
5b89d2c834 IRGen: OutliningCollector's bindPolymorphicParameters needs to disambiguate between Formal and Representational metadata types
A recent change removed the usage of LocalTypeDataKind when populating the local
type metadata cache. This change reintroduces it.

rdar://141961121
2025-01-03 09:13:59 -08:00
Arnold Schwaighofer
97b154875d Merge pull request #78321 from aschwaighofer/propagate_large
LargeLoadable types: propagate large type property along projections
2025-01-02 07:32:28 -08:00
Finagolfin
c69a12ce39 [android] Use emulated thread-local storage for API 28 and earlier
Android before API 29 and a few other platforms don't support native TLS, so
fall back to LLVM's emulated TLS there, just like clang does. Also, make sure
`-Xcc -f{no-,}emulated-tls` flags passed in are applied to control what the
Swift compiler does.
2024-12-30 23:07:58 +05:30
Augusto Noronha
d75bde3852 [DebugInfo] Fix debug info round tripping of types inside functions
Types with @_originallyDefinedIn cannot be round tripped,

Types declared inside functions have their mangling affected by the
function signature. If the generic signature mentions an
@_originallyDefinedIn type, the type inside the function cannot be round
tripped either.

This commit disables round tripping for this scenario.
2024-12-20 14:13:17 -08:00
Arnold Schwaighofer
be5223f0fa LargeLoadable types: propagate large type property along projections
Back propagate the isLargeType property along projections. This is
neccessary because c union types can "hide" largeness.

rdar://141775951
2024-12-20 09:09:42 -08:00
Anthony Latsis
cd1ef24c49 Merge pull request #78309 from AnthonyLatsis/nymphaea
Assortment of small fixes and cleanups
2024-12-20 06:51:19 +00:00
Anthony Latsis
7793f638d5 [NFC] AST: Consolidate some repeated DependentMemberType logic in Type methods 2024-12-20 02:47:29 +00:00
Egor Zhdan
fe5b047bdc [cxx-interop] NFC: Remove unused variable
This fixes a `-Wunused-variable` warning that got introduced in 57c7ecd2.
2024-12-19 16:50:44 +00: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
Augusto Noronha
dccc52d07e Merge pull request #78104 from augusto2112/orig-defined-in
[DebugInfo] Fix handling of @_originallyDefinedIn types
2024-12-18 13:38:55 -08:00
Dario Rexin
5efb6df3c0 [IRGen] Indirectly pass typed errors for closures with indirect results
rdar://141575655

In partial application forwarder emission, we were missing a check for indirect results.
When results are being returned indirectly, we have to return the error indirectly as well.
2024-12-17 15:09:50 -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
Augusto Noronha
72b0120b43 [DebugInfo] Fix handling of @_originallyDefinedIn types
Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961
2024-12-16 10:28:18 -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
nate-chandler
911e29e805 Merge pull request #78130 from nate-chandler/rdar141228350
[BitwiseCopyable] Fix resilient enum type info.
2024-12-13 11:25:26 -08:00
Nate Chandler
96a1c0c322 [BitwiseCopyable] Fix resilient enum type info.
Like other `EnumTypeInfo`s, the `TypeInfo` subclasses `EnumTypeInfoBase`
and store the `EnumImplStrategy`.
2024-12-11 17:54:17 -08:00
Kuba Mracek
af6b24b542 [embedded] Don't emit metadata references from C++ interop 2024-12-10 15:56:37 -08:00
Arnold Schwaighofer
fe00d20db2 Merge pull request #78017 from aschwaighofer/anon_context_desc
IRGen: Fix anonymous context descriptors of alwaysEmitIntoClient functions
2024-12-10 11:19:45 -08:00
Saleem Abdulrasool
8473d40f50 lib: use CXX_MODULE_NAME constant for module identifier (NFC)
Use the well known specifier for explicit references to the `Cxx` module
rather than re-spelling the name at the various sites.
2024-12-09 13:34:06 -08:00
Arnold Schwaighofer
d31e4a5745 IRGen: Fix anonymous context descriptors of alwaysEmitIntoClient functions
Relative references from context descriptors to types outside of the
current module need to use indirect relative references

rdar://140356479
2024-12-06 09:16:38 -08:00
Gábor Horváth
72846769f1 Merge pull request #77893 from swiftlang/gaborh/remove-rdar 2024-12-05 21:42:21 -08:00
Dario Rexin
38e36784d0 [IRGen] Check if type is empty instead of void in CallEmission::emitToUnmappedExplosionWithDirectTypedError
rdar://140573912

This caused assertions to fail when using other empty types, like `Never` as the result type on typed throwing functions.
2024-12-04 13:57:48 -10:00
Konrad `ktoso` Malawski
ed5007f6b1 Merge pull request #77584 from ktoso/wip-check-array-calls 2024-12-04 21:01:36 +09:00
Kuba (Brecka) Mracek
8792efedf0 Merge pull request #77115 from kubamracek/embedded-mangling-prefix
[Mangling] [NFC] Prepare for a new mangling prefix for Embedded Swift: $e
2024-12-03 08:10:49 -08:00
Gabor Horvath
f1ac9af3f9 [cxx-interop] Remove stale reference to rdar
There is no reason to require a body for move/copy ctors to use them.
2024-12-03 10:58:26 +00:00
Konrad `ktoso` Malawski
7189aded61 [Distributed] minor cleanups, remove dump=always from tests 2024-12-03 14:59:16 +09:00
Konrad `ktoso` Malawski
138f145ab9 [Distributed] @Resolvable now handles primary associated types in protocols
Previously we would not propagate those into the generated distributed
actor, making a lot of generic distributed actor protocols impossible to
express.

We indeed cannot handle protocols WITHOUT primary associated types, but
we certainly can handle them with!

This resolves rdar://139332556
2024-12-03 14:59:15 +09:00
Pavel Yaskevich
8a0a083a45 Merge pull request #77797 from xedin/locatable-types
[AST/Sema]  Introduce a new type that has associated location in source
2024-12-02 16:33:43 -08:00