Commit Graph

12796 Commits

Author SHA1 Message Date
Erik Eckstein
c11408ea2f IRGen: Don't let the offset of an empty field be undef.
If the field address comes from a struct_element_addr which is a result of an optimized `MemoryLayout<S>.offset(of: \.field)` we cannot return undef.
We have to be consistent with `offset(of:)`, which returns 0.
Therefore we need to return the base address of the struct.

rdar://117265274
2024-03-11 15:21:03 +01:00
Konrad `ktoso` Malawski
143d8f9801 [Distributed] Handle distributed thunk requirements/witnesses (#72151)
Co-authored-by: Pavel Yaskevich <pyaskevich@apple.com>
2024-03-11 02:07:22 -07:00
Arnold Schwaighofer
b35be130a6 Simplify code 2024-03-10 16:14:16 -07:00
Arnold Schwaighofer
d8936ff51f Guard a call to dump() in NDEBUG 2024-03-10 09:22:49 -07:00
Arnold Schwaighofer
ea70aea43c IRGen: Add code to support building fragile resilient protocol witnesses
We don't currently support building resilient relative protocol witness tables.
One might want to build with relative witness tables but not need
resilient protocols. Allow for that scenario.

Add a test configuration to test library-evolution + fragile resilient
protocols + relative protocol witness tables.
2024-03-10 09:14:08 -07:00
nate-chandler
877f471c97 Merge pull request #72211 from nate-chandler/var_decl-alloc_stack
[SIL] Key consume addr checking off var_decl attr.
2024-03-09 13:58:57 -08:00
Nate Chandler
34dd4aa0cb [IRGen] Collect metadata for empty types fields.
Previously, when the metadata collector only collected for layout, it
was wasteful to visit the empty fields of records.  Now that the field
may require a deinit call, it's necessary to visit it.

rdar://123577998
2024-03-08 22:19:28 -08:00
Nate Chandler
5ccec0e31c [NFC] SIL: Shortened member name.
Renamed "getUsesMoveableValueDebugInfo" to "usesMoveableValueDebugInfo".
Clarifies the predicate from "does the receiver have the
usesMoveableValueDebugInfo field set?" to "does the receiver use moveable
value debug info?".
2024-03-08 21:24:38 -08:00
Nate Chandler
571a673f21 [NFC] IRGen: Added debugging info.
In debug builds, provide some context when a witness table fails to be
found.
2024-03-08 21:01:16 -08:00
Adrian Prantl
7f5194b57e Merge pull request #72197 from adrian-prantl/better-scope-check
Detect methods by their scope rather than their representation.
2024-03-08 17:21:12 -08:00
Adrian Prantl
654df59161 Detect methods by their scope rather than their representation.
In the end this condition exists to avoid a BitCode Verifyer check that operates
off the scope, so looking for that directly is more future-proof.

rdar://123334375
2024-03-08 13:29:44 -08:00
Pavel Yaskevich
b17f0b534c Merge pull request #71855 from xedin/fix-sendable-keypath-conformance-issues
[AST] Special handling for existentials with superclass and marker pr…
2024-03-08 13:06:01 -08:00
Doug Gregor
0ef978acc0 Merge pull request #72163 from DougGregor/noncopyable-field-reflection-heuristic 2024-03-07 20:32:12 -08:00
John McCall
8499640224 Merge pull request #72143 from rjmccall/builtin-create-task
Unify and simplify the task-creation builtins
2024-03-07 21:45:06 -05:00
Emil Pedersen
653e8fd036 [DebugInfo] Add labels when constructing DebugTypeInfo (NFC) 2024-03-07 15:52:17 -08:00
Emil Pedersen
4ede40e2f7 [DebugInfo] Remove passing of the unused SizeIsFragmentSize (NFC) 2024-03-07 15:21:44 -08:00
Doug Gregor
73552d0a1b Emit reflection metadata for noncopyable fields more often
When emitting reflection metadata for fields that have noncopyable
type with deployment targets that predate support for noncopyable
types, we introduce some indirection to make sure that these fields
are only visible to reflection clients (e.g., mirrors) when running on
a sufficiently-new Swift runtime. However, this indirection has the
downside that out-of-process clients (such as LLDB) can no longer
reflect the fields.

Tweak the heuristic to only introduce the indirection if the field is
*guaranteed* to have noncopyable type. If it somehow could be
copyable, e.g., based on the properties of its generic arguments, then
still emit the normal metadata. This eliminates regressions when
existing generic types like Optional become conditionally Copyable
(based on their Wrapped functions).
2024-03-07 14:24:00 -08:00
Pavel Yaskevich
0ab7e12aa2 [IRGen] Strip marker protocols from type symbol's mangling 2024-03-07 13:31:39 -08:00
Emil Pedersen
456b5a0ac8 [DebugInfo] Move type size information to CompletedDebugTypeInfo (NFC) 2024-03-07 13:07:43 -08:00
Kavon Farvardin
d5ca8ee13e Merge pull request #72137 from kavon/ncgenerics-conditional-conformances
GenProto: drop conditional Copyable reqs from protocol conformance descriptors
2024-03-07 11:14:51 -08:00
Doug Gregor
e1ee19ac5e [Noncopyable generics] Suppress inverse conformance mangling for more symbols
Don't mangle inverse conformances for symbols related to dispatch thunks,
protocol members, and other entities that are inexorably tied to the
primary definition of the type and must have stable names.

Extend the conditional suppression of inverse conformance mangling to
property descriptors and more conformance-related symbols.
2024-03-07 10:01:20 -08:00
Doug Gregor
ed745a5c07 Merge pull request #72142 from DougGregor/preinversegenerics-extensions
Allow @_preInverseGenerics on extensions
2024-03-07 10:00:40 -08:00
Doug Gregor
66801fd572 Merge pull request #72145 from apple/revert-72130-no-inverse-mangle-reabstraction
Revert "Don't mangle inverse protocols within reabstraction thunks"
2024-03-07 08:23:54 -08:00
Pavel Yaskevich
d66eeae5ed Merge pull request #72107 from xedin/rework-getting-types-from-system
[AST/Sema] Distributed: Refactor type and member queries
2024-03-07 00:14:53 -08:00
John McCall
0a282c044f Unify all of the task-creation builtins coming out of SILGen.
We've been building up this exponential explosion of task-creation
builtins because it's not currently possible to overload builtins.
As long as all of the operands are scalar, though, it's pretty easy
to peephole optional injections in IRGen, which means we can at
least just use a single builtin in SIL and then break it apart in
IRGen to decide which options to set.

I also eliminated the metadata argument, which can easily be recreated
from the substitutions.  I also added proper verification for the builtin,
which required (1) getting `@Sendable` right more consistently and (2)
updating a bunch of tests checking for things that are not actually
valid, like passing a function that returns an Int directly.
2024-03-06 22:21:12 -05:00
Doug Gregor
5ec97ae4d7 Revert "Don't mangle inverse protocols within reabstraction thunks" 2024-03-06 19:11:32 -08:00
Doug Gregor
66651de832 Merge pull request #72130 from DougGregor/no-inverse-mangle-reabstraction
Don't mangle inverse protocols within reabstraction thunks
2024-03-06 18:26:13 -08:00
Doug Gregor
3745b5a5e7 Allow @_preInverseGenerics on extensions 2024-03-06 17:42:50 -08:00
Emil Pedersen
75015b5050 [DebugInfo] Remove accessor for type size in DebugTypeInfo 2024-03-06 17:42:40 -08:00
Emil Pedersen
01c752e6db [DebugInfo] Use LLVM type size instead of an estimate for types 2024-03-06 17:23:26 -08:00
Doug Gregor
b414a93f4e Merge pull request #72127 from DougGregor/mangle-generalized-ext-without-inverses
Disable mangling of inverses for generalized existential shape symbols
2024-03-06 16:33:37 -08:00
Kavon Farvardin
2e01f4ebf5 GenProto: drop cond. Copyable reqs from descriptor 2024-03-06 16:30:39 -08:00
Emil Pedersen
7c9a8769a1 Merge pull request #72072 from Snowy1803/tuple-fragments
Add support for op_tuple_fragment in SIL DIExpression and SIL SROA
2024-03-06 15:20:08 -08:00
Doug Gregor
cab88d15f3 Don't mangle inverse protocols within reabstraction thunks 2024-03-06 14:40:11 -08:00
Pavel Yaskevich
53c9049b99 [AST] NFC: Move distributed actor methods from ASTContext into swift namespace 2024-03-06 13:51:14 -08:00
Doug Gregor
f269cb5fbe Disable mangling of inverses for generalized existential shape symbols 2024-03-06 13:41:49 -08:00
Adrian Prantl
db237bc7a9 Merge pull request #72096 from adrian-prantl/reference-loop
Avoid copy of loop temporary
2024-03-06 13:20:54 -08:00
Allan Shortlidge
c17c19a200 Merge pull request #72109 from tshortli/maccatalyst-ldprevious
TBDGen: Specify the correct macCatalyst platform ID in `$ld$previous` directives
2024-03-06 10:58:53 -08:00
Konrad `ktoso` Malawski
746521b31c Merge branch 'main' into distributed-protocol-requirement-accessors 2024-03-06 12:52:41 +09:00
Allan Shortlidge
f49dbb06b6 TBDGen: Specify the correct macCatalyst platform ID in $ld$previous directives.
Resolves rdar://123491072
2024-03-05 19:05:19 -08:00
Kavon Farvardin
e2d33ecd5f Merge pull request #71878 from kavon/ncgenerics-mangling-2
NCGenerics: New Inverse Mangling 3DS XL
2024-03-05 18:15:40 -08:00
Allan Shortlidge
9a0598cda7 TBDGen: Use LinkerPlatformId enum type instead of casting to uint8_t.
Increase type safety by consistently using the `LinkerPlatformId` enum type,
instead of casting to/from `uint8_t` unnecessarily.

NFC.
2024-03-05 14:51:38 -08:00
Kavon Farvardin
215bd3cab4 Mangling: handle inverse requirements 2024-03-05 14:19:00 -08:00
Adrian Prantl
b5d83afaba Avoid copy of loop temporary 2024-03-05 12:16:14 -08:00
Pavel Yaskevich
c00c692c96 [IRGen] Distributed: Fix distributed actor metadata referencing when ObjC interop is disabled 2024-03-04 17:46:49 -08:00
Pavel Yaskevich
89e4fb25d6 [IRGen] Distributed/NFC: Switch from ASTMangler to IRGenMangler 2024-03-04 15:59:57 -08:00
Pavel Yaskevich
b443266580 [IRGen] Distributed: Start emitting distributed actor accessors for protocol requirements 2024-03-04 15:59:57 -08: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
Emil Pedersen
35e346fd8d Add support for op_tuple_fragment in SIL DIExpression and SIL SROA
rdar://124034536
2024-03-04 15:46:02 -08:00