Commit Graph

12064 Commits

Author SHA1 Message Date
Arnold Schwaighofer
4b0328f24f IRGen: Also list specialized generic class' objective c ro data in the dedicated linker section
List the emitted ro_data of specialized generic classes in the
__objc_clsrolist section.

rdar://132354480
2024-07-31 12:52:50 -07:00
Alejandro Alonso
ca8c90ecc0 Support movesAsLike for the array variant of @_rawLayout 2024-07-28 10:29:57 -07:00
Dario Rexin
90a9ffdf02 [IRGen] Properly compute bit mask for extra tag bits in CVW
rdar://132501359

PowerOf2Ceil is not the correct function to use, because we end up with an empty mask if there is only one value stored in the extra tag bits
2024-07-26 14:50:54 -07:00
Konrad `ktoso` Malawski
eb675c222e [Distributed] Correct tbd handling for distributed thunks (#74935) 2024-07-26 16:52:18 +09:00
Allan Shortlidge
54301e4f0f IRGen: Update AllocStackHoisting for macCatalyst.
Teach `inhibitsAllocStackHoisting` about the `targetVariantOSVersionAtLeast`
and `targetOSVersionOrVariantOSVersionAtLeast` builtins.
2024-07-23 17:00:10 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Allan Shortlidge
bb8a837dcf IRGen: Honor -target-variant flag for zippered macCatalyst binaries. 2024-07-23 17:00:10 -07:00
Dario Rexin
e0d9da454c [IRGen] Properly extract values in visitThrowInst for empty error
rdar://132122011

For async functions we have to extract the values, which was not happening when the error type was empty.
2024-07-19 17:01:13 -07:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Gábor Horváth
e836e2caeb Merge pull request #75176 from swiftlang/gaborh/inheritance-2
[cxx-interop] Fix wrong field offsets with value types using inheritance
2024-07-18 03:59:47 -07:00
Dario Rexin
e3577ed266 Merge pull request #75316 from drexin/wip-131960281
[IRGen] Skip async context params before handling direct error return…
2024-07-17 19:00:46 -07:00
Dario Rexin
99db2dcc61 [IRGen] Skip async context params before handling direct error return values
rdar://131960281

We need to skip the async context params, otherwise we load the wrong parameters.
2024-07-17 15:47:29 -07:00
Gábor Horváth
1b4bba3cec Update lib/IRGen/GenStruct.cpp
Co-authored-by: John McCall <rjmccall@apple.com>
2024-07-17 09:32:23 +01:00
Gábor Horváth
824fccac92 Update lib/IRGen/GenStruct.cpp
Co-authored-by: John McCall <rjmccall@apple.com>
2024-07-17 09:32:17 +01:00
Dario Rexin
c276904372 Merge pull request #75270 from drexin/wip-131798355
[IRGen] Fix emitPrimitiveLoadPayloadAndExtraTag for CVW
2024-07-16 13:46:55 -07:00
Kavon Farvardin
fedd5e2977 Merge pull request #74864 from kavon/ncgenerics-runtime-demangling-fix 2024-07-16 13:38:15 -07:00
Dario Rexin
e3e06a79e4 [IRGen] Fix emitPrimitiveLoadPayloadAndExtraTag for CVW
rdar://129627898

When casting the projectedBits to Int8, we accidetnally passed the base addr instead of the projectedBits. This was causing the wrong bits to be read.
2024-07-16 10:35:01 -07:00
Kavon Farvardin
d755e90236 NCGenerics: limit field metadata heuristic
We have had a heuristic that lets you reflect fields of types, where
the field's type is conditionally Copyable, despite the reflection
infrastructure always copying a field. That heuristic was added to allow
ubiquitous types like Optional in the stdlib to continue to be
reflected, even if the Optional at runtime really isn't Copyable.

As a consequence, we were also allowing reflection of fields containing
user-defined conditionally copyable types, when that's unsafe for no
real benefit, yielding runtime crashes!

I think in that case it's better to fall-back on the non-crashy case of
reflection seeing it as the EmptyTupleType, which isn't inhabited, so it
won't try to copy the field and instead basically skip-over it until a
future runtime supports the reflection safely.

So, this patch limits the dangerous reflection to only stdlib-defined
types, until Mirror and friends are updated.
2024-07-15 22:10:17 -07:00
Kavon Farvardin
76bb266624 NCGenerics: fix runtime demangling strategy
We generally should use the open-coded, metadata function "accessor"
strategy when targeting older runtimes, but if the type is part of
the stdlib, assume the runtime demangler will produce correct
metadata, as the retrofitting of Optional, etc, was done Carefully.

resolves rdar://131337585
2024-07-15 22:10:17 -07:00
Dario Rexin
14df7a1db9 Merge pull request #75246 from drexin/wip-131352085
Revert "[IRGen] Fetch the correct IGM for synthesized files"
2024-07-15 15:32:15 -07:00
Dario Rexin
a401d15ea5 Revert "[IRGen] Fetch the correct IGM for synthesized files"
rdar://131352085

This change caused the problems it was supposed to fix for Macros to appear with Differentiation.

This reverts commit d33f2c4ba1.
2024-07-15 10:47:42 -07:00
Dario Rexin
9b1a82d9ec [IRGen] Add direct error return support for async functions
rdar://129359370

Second part of direct error support. This implements direct errors for async functions. Instead of always returning typed errors indirectly, we are returning them directly when possible.
2024-07-13 17:02:32 -07:00
Gabor Horvath
ce3fa734ce [cxx-interop] Fix wrong field offsets with value types using inheritance
Instead of adding opaque fields for the base subobjects this patch
introduces a recursive walk to add all the base fields to the generated
Swift struct.

rdar://126754931
2024-07-11 17:20:18 +01:00
Slava Pestov
c345ba94c8 Merge pull request #75164 from slavapestov/irgen-collect-link-libraries
AST: Optimize collectLinkLibraries()
2024-07-11 09:00:14 -04:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Dario Rexin
8fca31efde Merge pull request #75150 from drexin/wip-130971168
[IRGen] Don't apply direct error return to functions with indirect result
2024-07-10 21:07:40 -07:00
Dario Rexin
32af2f6c19 Merge pull request #75149 from drexin/wip-ptr-cast-tt
[IRGen] Apply int to ptr conversion for direct error returns if neces…
2024-07-10 20:37:49 -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
Slava Pestov
d1847ffde7 Merge pull request #75068 from slavapestov/simplify-sub-map
Simplify and optimize SubstitutionMap
2024-07-10 20:45:56 -04:00
Dario Rexin
e3c0bc880c [IRGen] Don't apply direct error return to functions with indirect result
rdar://130971168

Having direct and indirect results on the same function is illegal.
2024-07-10 16:11:03 -07:00
Dario Rexin
11a55de697 [IRGen] Apply int to ptr conversion for direct error returns if necessary
rdar://131494255

When merging a ptr into an int value for direct error return, we have to properly convert it back to a pointer at the callsite
2024-07-10 16:09:39 -07:00
Meghana Gupta
fecd2b452d Don't mangle lifetime dependencies in older runtimes 2024-07-10 14:48:34 -07:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
45490894c4 IRGen: Reduce type witnesses in hasDependentTypeWitness() 2024-07-10 13:28:22 -04:00
Dario Rexin
22b6319c71 Merge pull request #75072 from drexin/wip-refactor-te-callemission
[IRGen] Move some typed error code in CallEmission into separate func…
2024-07-08 17:48:16 -07:00
Dario Rexin
25929b3b4d [IRGen] Move some typed error code in CallEmission into separate function
This is in preparation of adding support for async calls, so the code can be shared between sync and async calls.
2024-07-08 12:28:02 -07:00
Slava Pestov
ca9c09f8a1 Remove some unused variables 2024-07-06 12:05:47 -04:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
3fcda140bb AST: ModuleDecl::checkConformance() is a static method 2024-07-06 12:05:46 -04:00
Slava Pestov
1901862afc AST: Remove LookUpConformanceInSignature 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Erik Eckstein
6ed2489aee IRGen: don't stack promote classes for which the layout has not a fixed size
In most cases this was already checked with `ClassLayout::isFixedLayout`. But for classes which are imported from another module and contain implementation-only C-imported stored properties, those properties don't show up in the class layout. Stack promoting such classes will reserve too less space on the stack which leads to all kind of memory corruption problems. The fix is to also check `ClassLayout::isFixedSize`, which returns false for such classes.

Fixes a miscompile
rdar://131067105
2024-07-04 17:03:31 +02:00
Doug Gregor
e50beb0a46 Merge pull request #74962 from DougGregor/typed-throws-backdeploy-fixes
Typed throws backdeploy fixes
2024-07-04 00:12:52 -07:00
Doug Gregor
9604019c87 Drop typed throws from the mangling in closure and field reflection metadata
This follows what we just did for `@isolated(any)` function types.

Part of rdar://130858222.
2024-07-03 20:14:01 -07:00
Dario Rexin
5dcd163c42 [IRGen] Always load extra tag bits as full bytes in CVW to avoid elemination of masking
rdar://129627898

LLVM expects integer types of fractional byte sizes to have been written as those types as well, so it expects all unused bytes to be 0.
Since we are using the unused extra tag bits to store tags of outer enums, that assumption does not hold here. In regular witnesses,
the outer enum would mask out those bytes before checking the tag of the inner enum. In CVW we can't do that, so we have to apply the
mask ourselves. To guarantee the mask does not get optimized out, we have to use full bytes instead of fractionals.
2024-07-03 12:32:07 -07:00
John McCall
2c6e0efb9c Suppress @isolated(any) in reflective metadata strings on old targets
Fix another aspect of rdar://129861211
2024-07-02 18:12:20 -04:00
Egor Zhdan
75a00adcf0 Merge pull request #74625 from swiftlang/egorzhdan/upstream-ptrauth-vwt
[IRGen] Upstream pointer auth for value witness tables
2024-07-01 22:17:59 +01:00
Egor Zhdan
b22057e637 [IRGen] Upstream pointer auth for value witness tables
This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.
2024-07-01 16:38:06 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00
Dario Rexin
b7c241df8e Merge pull request #74717 from drexin/wip-128870792
[IRGen] Fetch the correct IGM for synthesized files
2024-06-29 07:33:17 -07:00