Commit Graph

9332 Commits

Author SHA1 Message Date
Slava Pestov
ec82f6bf4d SIL: Remove SILWitnessTable::AssociatedConformanceWitness::SubstType 2025-04-07 21:36:06 -04:00
Slava Pestov
b94a0448f2 SIL: Remove SILWitnessTable::ConditionalConformance 2025-04-07 21:36:05 -04:00
Andrew Trick
501abb0975 Add SILFunctionType::isAddressable & ApplySite::isAddressable. 2025-04-07 14:42:10 -07:00
Gabor Horvath
6b863f9575 [cxx-interop] Fix calling rvalue ref of a trivial type
The Swift compiler used to generate a direct call to functions taking
rvalue references to trivial types even though they expected an indirect
calling conventions. This PR changes the calling convention on the Swift
side to match C++.

rdar://148585343
2025-04-06 18:58:12 +01:00
eeckstein
98739a412a Merge pull request #80543 from eeckstein/isolated-conformance-opt
CastOptimizer: handle isolated conformances
2025-04-06 10:59:51 +02:00
Anthony Latsis
08d46d2542 Merge pull request #80473 from AnthonyLatsis/diag_type_attr
DiagnosticEngine: Support `TypeAttribute` diagnostic arguments
2025-04-05 12:25:45 +01:00
Erik Eckstein
75a0cc031b CastOptimizer: handle isolated conformances
Check the isolation of conformances to avoid wrong folding of dynamic casts
rdar://147417762
2025-04-05 09:00:30 +02:00
Erik Eckstein
e18bedaa87 CastOptimizer: pass the SIL function to the cast-classify APIs, instead of the module decl
NFC
2025-04-05 09:00:30 +02:00
Erik Eckstein
9df1039379 SIL: add matchesActorIsolation
Returns true if the conformance is not isolated or if its isolation matches the isolation `inFunction`.
2025-04-05 09:00:30 +02:00
eeckstein
6f68a86c3e Merge pull request #80530 from eeckstein/fix-sil-linker
embedded: fix two problems in the SILLinker
2025-04-04 19:34:05 +02:00
Erik Eckstein
14ff3ea05f SILLinker: de-serialize Executor witness tables for the xExecutorRef builtins
Fixes unresolved symbol linker errors in embedded mode.
rdar://148538336
2025-04-04 14:32:48 +02:00
Erik Eckstein
e68882e8a3 SILLinker: make sure to de-serialize base protocol witness tables in embedded mode
Fixes unresolved symbol linker errors or compiler crashes
rdar://148538336
2025-04-04 14:32:48 +02:00
Slava Pestov
e475b08011 AST: Remove AssociatedType 2025-04-03 17:35:35 -04:00
Slava Pestov
a06a4213ef AST: Remove origType parameter from substOpaqueTypesWithUnderlyingTypes() 2025-04-03 17:35:34 -04:00
Slava Pestov
a209ff8869 AST: Remove origType parameter from ProtocolConformanceRef::subst() 2025-04-03 17:35:33 -04:00
Slava Pestov
00766f7deb AST: Remove type parameter from ProtocolConformanceRef::getTypeWitnessByName() 2025-04-03 17:35:32 -04:00
eeckstein
70bc9cdb1f Merge pull request #80486 from eeckstein/fix-struct-extract
SIL: fix the ownership computation of `struct_extract` and `tuple_extract`
2025-04-03 18:32:07 +02:00
Erik Eckstein
0b9f5eb86c SIL: add some asserts to catch broken enum ASTs 2025-04-03 08:14:42 +02:00
Erik Eckstein
f1fc864dc6 SIL: fix the ownership computation of struct_extract and tuple_extract
A struct or tuple value can have "none" ownership even if its type is not trivial.
This happens when the struct/tuple contains a non-trivial enum, but it's initialized with a trivial enum case (e.g. with `Optional.none`).

```
  %1 = enum $Optional<String>, #Optional.none!enumelt
  %2 = struct $S (%32)               // has ownership "none"
  %3 = struct_extract %2, #S.x       // should also have ownership "none" and not "guaranteed"
```

So far it got "guaranteed" ownership which is clearly wrong.

Fixes an assertion crash in redundant load elimination.

https://github.com/swiftlang/swift/issues/80430
rdar://148311534
2025-04-03 06:40:26 +02:00
Anthony Latsis
99f63ed933 DiagnosticEngine: Support TypeAttribute diagnostic arguments 2025-04-03 01:52:38 +01:00
Joe Groff
562d7dc832 Merge pull request #80438 from jckarter/substitute-away-escapable-lifetime-deps
Type substitution eliminates dependencies with Escapable targets.
2025-04-02 16:56:54 -07:00
Joe Groff
6b605f41cb Type substitution eliminates dependencies with Escapable targets.
When a generic function has potentially Escapable outputs, those outputs
declare lifetime dependencies, which have no effect when substitution
leads to those types becoming `Escapable` in a concrete context.
This means that type substitution should canonically eliminate lifetime
dependencies targeting Escapable parameters or returns, and that
type checking should allow a function value with potentially-Escapable
lifetime dependencies to bind to a function type without those dependencies
when the target of the dependencies is Escapable.

Fixes rdar://147533059.
2025-04-02 08:54:45 -07:00
Allan Shortlidge
918c6c32cb SIL: Fix a -Wimplicit-fallthrough warning. 2025-04-01 13:11:36 -07:00
Artem Chikin
66334f8f1b Merge pull request #79290 from artemcm/ConstProtoSIL
[Compile Time Values] Implement a mandatory SIL pass to verify '@const' values
2025-04-01 00:12:27 -07:00
Shubham Sandeep Rastogi
65a515b2d4 Merge pull request #80079 from rastogishubham/EnhanceDump
Add dump overloads to print debug info for SIL.
2025-03-31 11:41:55 -07:00
Artem Chikin
281f84da0f [Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift 2025-03-28 10:30:07 -07:00
Anthony Latsis
fffa8c2f51 Diag: Abstract away some calls to DeclAttribute::getAttrName 2025-03-28 02:01:27 +00:00
Artem Chikin
72a420919a [Compile Time Values] Add mandatory optimization pipeline driver for '@const' globals 2025-03-27 14:33:38 -07:00
Artem Chikin
d484ec7c1f [Compile Time Values] Implement a mandatory SIL pass to verify '@const' values 2025-03-27 14:33:35 -07:00
Doug Gregor
e0b52cd20e [SIL] Extend checked-cast instructions with "prohibit isolated conformances" flag
When performing a dynamic cast to an existential type that satisfies
(Metatype)Sendable, it is unsafe to allow isolated conformances of any
kind to satisfy protocol requirements for the existential. Identify
these cases and mark the corresponding cast instructions with a new flag,
`[prohibit_isolated_conformances]` that will be used to indicate to the
runtime that isolated conformances need to be rejected.
2025-03-26 22:31:47 -07:00
Michael Gottesman
de7a62e13e Merge pull request #80312 from gottesmm/pr-126bc735b2d01c0f2f35f27268ff26d404b2fb16
[sil] Make SILFunctionTypeInfo a struct enum.
2025-03-26 18:05:57 -07:00
Shubham Sandeep Rastogi
b016c742c6 Add dump overloads to print debug info for SIL.
This patch adds dump overload methods to SILInstruction, SILBasicBlock,
SILFunction, and SILModule that prints the debug information as well.
2025-03-26 10:47:45 -07:00
Becca Royal-Gordon
5bb6245a5a [NFC] Check that SILGen doesn’t use ABI-only decls
Adds assertions in various places where properties that can vary between ABI-only decls and their counterparts—particularly function and parameter attributes—are handled in SILGen, ensuring that we don’t accidentally end up processing ABI-only decls there.
2025-03-26 10:47:13 -07:00
Andrew Trick
97b249bd11 Merge pull request #80263 from atrick/markdep-addr
SIL: add mark_dependence_addr
2025-03-26 10:33:42 -07:00
Michael Gottesman
8cfb029b5c [sil] Make SILFunctionTypeInfo a struct enum.
I am doing this in preparation for adding the ability to represent in the SIL
type system that a function is global actor isolated. Since we have isolated
parameters in SIL, we do not need to represent parameter, nonisolated, or
nonisolated caller in the type system. So this should be sufficient for our
purposes.

I am adding this since I need to ensure that we mangle into thunks that convert
execution(caller) functions to `global actor` functions what the global actor
is. Otherwise, we cannot tell the difference in between such a thunk and a thunk
that converts execution(caller) to execution(concurrent).
2025-03-26 10:23:44 -07:00
John McCall
4da795fd61 Merge pull request #80297 from rjmccall/zero-objc-async-result-on-error-path
Pass a zero normal result to ObjC async completion handlers on the error path
2025-03-26 12:42:38 -04:00
Andrew Trick
d9dd93560d Support mark_dependence_addr in SIL passes. 2025-03-25 23:02:45 -07:00
Andrew Trick
e7000e4668 SIL: Add mark_dependence_addr 2025-03-25 23:02:42 -07:00
John McCall
3fe70968cc Remove the substitution map from zeroInitializer builtin in SIL.
This is a value operation that can work just fine on lowered types,
so there's no need to carry along a formal type. Make the value/address
duality clearer, and enforce it in the verifier.
2025-03-26 00:34:15 -04:00
Kuba (Brecka) Mracek
1c395e24f6 Merge pull request #79923 from kubamracek/mracek/constinitialized
[Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature
2025-03-25 13:41:17 -07:00
nate-chandler
17952d4d6f Merge pull request #80221 from nate-chandler/general-coro/20250320/1
[CoroutineAccessors] Default overrides of new symbols.
2025-03-25 12:22:40 -07:00
Michael Gottesman
7648bce91b Merge pull request #80210 from gottesmm/pr-5cf03315e9a3442419b1bab18b46f755fdf0b405
[concurrency] Make sure that TypeLowering inserts the extra actor parameter for @execution(caller) parameters.
2025-03-25 10:09:44 -07:00
Nate Chandler
a3ba93609e [DefaultOverrides] SIL de/serialization. 2025-03-25 07:22:40 -07:00
Nate Chandler
317a379693 [DefaultOverrides] SIL printing/parsing. 2025-03-25 07:22:14 -07:00
Nate Chandler
89e5e3dfca [DefaultOverrides] SIL representation.
See the comment in SILDefaultOverrideTable.h for details.
2025-03-25 07:22:14 -07:00
Nate Chandler
e6c03bd278 [Gardening] Tweak comment. 2025-03-25 07:22:12 -07:00
Nate Chandler
10264ad893 [Gardening] Tweak comment. 2025-03-25 07:22:12 -07:00
Kuba Mracek
f402eb623c [Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature 2025-03-24 09:31:57 -07:00
Andrew Trick
d97a8cec64 Merge pull request #80223 from atrick/enable-addressable
LifetimeDependence: enable addressable dependencies
2025-03-24 08:30:01 -07:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00