Commit Graph

6754 Commits

Author SHA1 Message Date
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
Joe Groff
98d6480ddb Merge pull request #80275 from jckarter/classify-address-projections
SILGen: Properly classify LValue component projections in more cases.
2025-03-26 09:16:09 -07:00
John McCall
e9ebc7c848 Pass a zero normal result to ObjC async completion handlers on the error path.
Fixes #65199
2025-03-26 00:58:27 -04: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
Joe Groff
f990413d39 SILGen: Properly classify LValue component projections in more cases.
PR #79084 adjusted the projection logic for addressor accessors to avoid
a temporary materialization in cases where the base value is already in
memory; however, many LValue physical components were still unconditionally
using `ManagedValue::forLValue` and causing unnecessary materializations
from already-read-accessed memory locations. Fixes rdar://147705667.
2025-03-25 09:55:31 -07:00
Nate Chandler
1c3073b804 [DefaultOverrides] SILGen.
Emit tables for open members of open classes.
2025-03-25 07:22:43 -07:00
Nate Chandler
cc4c4584bf [NFC] SILGen: Extract base class.
Add new SILGenVTableBase class as a parent of SILGenVTable in
preparation to add another subclass.
2025-03-25 07:22:43 -07:00
Nate Chandler
71412d3566 [NFC] SILGen: Name operation.
And prepare to reuse it.
2025-03-25 07:22:43 -07:00
Nate Chandler
ea0387ad9d [NFC] SILGen: Extract typealias. 2025-03-25 07:22:43 -07:00
Alejandro Alonso
241ffafe7f Merge pull request #80245 from Azoy/ia-literal-closure
[SILGen] Use the opaque element type for address in InlineArray literal
2025-03-24 23:21:06 -07:00
Alejandro Alonso
bc6c88bfb1 Use the opaque element type for address in InlineArray literal 2025-03-24 10:35:14 -07:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Joe Groff
b467d842c5 Merge pull request #80133 from jckarter/synchronize-vtable-layout-and-entry-emission-visibility
SILGen: Fix inconsistency between vtable layout and vtable entry emission.
2025-03-20 13:06:33 -07:00
Tony Allevato
8c43428acd Merge pull request #80118 from allevato/uninitialized-capture
[NFC] Fix a use of an uninitialized captured value.
2025-03-20 11:32:20 -04:00
Amritpan Kaur
3c30d68d2e Merge pull request #78823 from amritpan/method-keypaths
[Sema/SILGen/IRGen] Implement method & initializer keypaths.
2025-03-19 18:59:17 -07:00
Joe Groff
9e5e240704 SILGen: Fix inconsistency between vtable layout and vtable entry emission.
As part of the criteria to determine whether a method override requires a new
vtable entry in addition to overriding the base class's vtable entry for the
method, we compare the visibility of the base class to that of the derived
class, since if further subclasses of the derived class cannot see the original
base class's method descriptor, they would not be able to directly override its
vtable entry.

However, there was a subtle inconsistency in our checks in two different
places: `NeedsNewVTableEntryRequest::evaluate` compared the visibility of the
derived method to its immediate override method, whereas
`SILGenModule::emitVTableMethod` compared visibility with the ultimate base
method that originated the vtable entry in question. Internal imports create
a situation where this leads to inconsistent answers, causing us to emit
a vtable thunk but without a corresponding new vtable entry, causing the thunk
to become self-recursive (rdar://147360093). If the base class is in a separate
module:

```
// Module1
open class Base {
    public required init() {}
}
```

and an intermediate class inherits that base class, it must `public import`
the module in the file defining the class to do so:

```
// Module2

public import Module1

open class MidDerived: Base { }
```

However, another file in the same module can further inherit that class, but
with only an `internal import` of the base module:

```
// Also Module2

import Module1

open class MostDerived: MidDerived { }
```

The implicit `init()` is `public` in each class, but from the perspective of
`MostDerived.init`, `Base.init` is `internal` because of the import. However,
the fact that its immediate parent is `public` should be sufficient evidence
that its original definition had visibility to `Base`, so no thunk should
be necessary.
2025-03-19 15:34:50 -07:00
Amritpan Kaur
807c323159 [SILGenExpr] Lower initializers. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
45a7b45ad9 [SILGen] Lower unapplied methods. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
4479996d7b [NFC] Refactor method thunk handling for reuse. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
60e03a85d9 [SILGen] Lower applied keypath methods. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
e5362c761d [NFC] Refactor subscript argument evaluation for reuse. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
91c94a608d [NFC] Refactor callee formation for reuse. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
ae86b0e96d [NFC] Refactor getter/setter logic for reuse. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
e7e354d989 [NFC] Generalize subscript code for methods. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
2583da94b2 [NFC] Generalize subscript index handling. 2025-03-19 08:53:18 -07:00
Amritpan Kaur
811d54901b [NFC] Rename unresolvedProperty to unresolvedMember
to generalize for both properties and method members.
2025-03-19 08:53:18 -07:00
Amritpan Kaur
8f71f5c780 [NFC] Rename property to member to generalize
for both properties and method members.
2025-03-19 08:53:18 -07:00
Tony Allevato
8b483a6a52 [NFC] Fix a use of an uninitialized captured value.
On a very recent tip-of-tree build of Clang, this was producing
the following error:

`variable 'eltMV' is uninitialized when used within its own initialization [-Werror,-Wuninitialized]`
2025-03-19 10:55:19 -04:00
Slava Pestov
8bcd09aaa4 SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanceWitness
The Protocol field isn't really necessary, because the conformance
stores the protocol. But we do need the substituted subject type
of the requirement, just temporarily, until an abstract conformance
stores its own subject type too.
2025-03-18 19:38:42 -04:00
Alejandro Alonso
223ebd2de0 Merge pull request #79994 from Azoy/fix-empty-inlinearray
[SILGen] Fix empty inline array literals
2025-03-18 09:23:00 -07:00
Joe Groff
85425fbe9c SILGen: Adjust allocation point for addressable representations.
Allocate the stack buffer at the point where the cleanup is introduced, so that
the stack allocations always follow scope stack discipline.
2025-03-17 21:37:08 -07:00
Alejandro Alonso
8b3499d90e Fix empty inline array literals 2025-03-13 09:53:28 -07:00
Joe Groff
8d04ba1a07 Merge pull request #79978 from jckarter/addressable-representation-silgen-2
SILGen: Emit an addressable representation for immutable bindings on demand. [take 2]
2025-03-13 08:39:44 -07:00
Alastair Houghton
3a7fc7c206 [Concurrency] Remove spurious printf().
Remove a printf() I'd added for debugging.

rdar://141348916
2025-03-13 13:37:43 +00:00
Alastair Houghton
55afa47bea [Concurrency] More work on the custom executor implementation.
Added an `-executor-factory` argument to the compiler to let you safely
specify the executors you wish to use (by naming a type that returns
them).

Also added some tests of the new functionality.

rdar://141348916
2025-03-13 13:34:41 +00:00
Joe Groff
da813458a6 SILGen: Emit an addressable representation for immutable bindings on demand.
To ensure that dependent values have a persistent-enough memory representation
to point into, when an immutable binding is referenced as an addressable
argument to a call, have SILGen retroactively emit a stack allocation and
materialization that covers the binding's scope.
2025-03-12 18:35:42 -07:00
Konrad `ktoso` Malawski
8c4dea9802 Revert "[concurrency] Add support for HopToMainActorIfNeededThunk." (#79938)
* Revert "[concurrency] Add support for HopToMainActorIfNeededThunk."

This reverts commit 0e0665bfbd.

* remove some last bits of 0e0665b
2025-03-13 06:48:03 +09:00
Michael Gottesman
f6349aaf1e Revert "SILGen: Emit an addressable representation for immutable bindings on demand."
This reverts commit 19a99ea42b.

rdar://146864906
2025-03-12 13:24:33 -07:00
Joe Groff
2df3211690 Merge pull request #79903 from jckarter/addressable-representation-silgen
SILGen: Emit an addressable representation for immutable bindings on demand.
2025-03-12 08:02:05 -07:00
Joe Groff
19a99ea42b SILGen: Emit an addressable representation for immutable bindings on demand.
To ensure that dependent values have a persistent-enough memory representation
to point into, when an immutable binding is referenced as an addressable
argument to a call, have SILGen retroactively emit a stack allocation and
materialization that covers the binding's scope.
2025-03-11 15:15:48 -07:00
Erik Eckstein
d225c47d25 AST: rename OpenArchetypeType -> ExistentialArchetypeType
NFC
2025-03-11 20:21:46 +01:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Rintaro Ishizaki
5eac58e1e0 [AST] SwitchStmt only hold CaseStmt
Now that there is no way SwitchStmt to hold AST nodes other than
CaseStmt.
2025-03-08 09:14:40 -08:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Michael Gottesman
17e30549b2 Merge pull request #79848 from gottesmm/pr-87b605dd36923c565ba5ca391df61dde2d835338
[silgen] Place hop_to_executor emission for an apply within a formal evaluation scope.
2025-03-07 18:13:49 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Michael Gottesman
2340dba27b [silgen] Place hop_to_executor emission for an apply within a formal evaluation scope.
Without this, the borrow of the hop_to_executor lasts after the apply. Beyond
being unnecessary this results in an OSSA violation if we are passing an actor
as an isolated parameter to an initializer since we hop_to_executor the actor
and then pass it as a +1 parameter to the initializer causing the actor to be
consumed before its borrow ends.

rdar://144994837
2025-03-07 11:51:22 -08:00
nate-chandler
38c8cc8ff4 Merge pull request #77661 from nate-chandler/general-coro/20241115/1
[CoroutineAccessors] Default implementations are transparent.
2025-03-07 11:39:21 -08:00