Commit Graph

12848 Commits

Author SHA1 Message Date
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
swift-ci
fcdf7014dc Merge remote-tracking branch 'origin/main' into rebranch 2024-07-17 19:10:50 -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
swift-ci
11d0ff8d80 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-16 13:55:15 -07: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
swift-ci
81a582e9f7 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-15 15:34:55 -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
swift-ci
49a48d8781 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-13 20:54:46 -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
swift-ci
0be42b6b18 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-11 06:14:58 -07: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
Mykola Pokhylets
816d62c972 Merge remote-tracking branch 'upstream/main' into mpokhylets/isolated-deinit
# Conflicts:
#	include/swift/Basic/Features.def
#	lib/SILGen/SILGenDestructor.cpp
#	test/Concurrency/flow_isolation.swift
#	test/abi/macOS/arm64/concurrency.swift
#	test/abi/macOS/x86_64/concurrency.swift
2024-07-11 13:11:59 +02:00
Mykola Pokhylets
b189495518 Introduced isolated deinit as a SIL entity 2024-07-11 13:09:05 +02:00
swift-ci
a32c1896dc Merge remote-tracking branch 'origin/main' into rebranch 2024-07-10 23:09:47 -07: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
swift-ci
787d4b51d2 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-10 21:13:31 -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
Ben Barham
2715d0e9d6 Merge branch 'main' into 20240710-main-to-rebranch
Conflicts:
  - `test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift`
    previously fixed on rebranch, now fixed on main (slightly differently).
2024-07-10 20:42:09 -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
swift-ci
b7921a8232 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-06 14:34:09 -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
swift-ci
9b22f7a183 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-05 00:13:41 -07: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
swift-ci
9148779681 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 00:15:21 -07: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
swift-ci
f0044fcfca Merge remote-tracking branch 'origin/main' into rebranch 2024-07-03 17:18:35 -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