Skip to content

Manually merge main to rebranch #77211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0fbbba5
[Explicit Module Builds] Initialize ClangImporter's 'CodeGenerator' u…
artemcm Dec 20, 2023
1b9ec9a
[concurrency] Fix x86_64/concurrency.swift ABI test to match the arm6…
gottesmm Oct 22, 2024
5cc9988
Add mailto format for [email protected] .
lamtrinhdev Oct 22, 2024
5e04811
Try to fix objc_attr_NSManaged.sil test on arm64e
aschwaighofer Oct 22, 2024
c58cc44
Support generic but concrete metatypes with hasSymbol
Azoy Oct 22, 2024
549262a
[SE-0449] Promote `GlobalActorInferenceCutoff` to upcoming feature.
simanerush Oct 22, 2024
a184782
Introduce a `Builtin.FixedArray` type.
jckarter Sep 23, 2024
308b4f4
Sema: Re-enable validation-test/Sema/type_checker_perf/slow/nil_coale…
slavapestov Oct 18, 2024
a48591d
Sema: Tail-allocate Constraint::TheFix
slavapestov Oct 11, 2024
0de8428
Sema: Tail-allocate Constraint::Overload::Choice
slavapestov Oct 11, 2024
2eaec5a
Sema: Remove Constraint::clone()
slavapestov Oct 11, 2024
b44bff2
Sema: Fold Constraint::createFixedChoice() into Constraint::createBin…
slavapestov Oct 11, 2024
53794d3
Sema: Rename ConstraintSystem::generateConstraints() to ConstraintSys…
slavapestov Oct 11, 2024
338ad30
Sema: Tighten an invariant in ConstraintGraph
slavapestov Oct 22, 2024
6c02529
Sema: Simplify ConstraintSystem::getUnopenedTypeOfReference()
slavapestov Oct 11, 2024
c728c2a
Sema: Simplify doesStorageProduceLValue()
slavapestov Oct 11, 2024
5416884
Sema: Don't split up pack types in matchExistentialTypes()
slavapestov Sep 25, 2024
3400022
Sema: Remove ConstraintKind::SelfObjectOfProtocol
slavapestov Sep 25, 2024
5e1e184
AST: Clean up ExistentialLayout for ParameterizedProtocolType
slavapestov Sep 25, 2024
8beaa7b
Sema: Fix matchExistentialType() handling of ProtocolCompositionType …
slavapestov Sep 25, 2024
b302445
[Test] Removed asserts requirement.
nate-chandler Oct 22, 2024
125b908
[Test] Used patterns for bbs.
nate-chandler Oct 22, 2024
f2e3e8e
[Sema] Permit read requirement.
nate-chandler Oct 22, 2024
f797e19
[Parse] Updated protocol diagnostic to allow read.
nate-chandler Oct 21, 2024
05b95b8
Sema: Reduce unnecessary exposure of availability checking helpers.
tshortli Oct 23, 2024
92d5656
Merge pull request #77172 from Azoy/generic-concrete-hassymbol
Azoy Oct 23, 2024
95aef6c
[Backtracing] Fix iOS build.
al45tair Oct 23, 2024
8242110
Merge pull request #76831 from jckarter/builtin-vector
jckarter Oct 23, 2024
3934f78
Merge pull request #77180 from tshortli/consolidate-availability-type…
tshortli Oct 23, 2024
4a12979
Merge pull request #77188 from al45tair/eng/PR-137551812-ios-fix
jckarter Oct 23, 2024
b7fd4e1
Merge pull request #77179 from nate-chandler/general-coro/20241017/1
nate-chandler Oct 23, 2024
3e2556d
Merge pull request #77170 from aschwaighofer/fix_objc_attr_NSManaged.sil
aschwaighofer Oct 23, 2024
0ac8cd3
Sema: Allow resilient modules to add enum elements without breaking c…
tshortli Oct 23, 2024
132726c
Merge pull request #77161 from lamtrinhdev/Update_CONTRIBUTING.md
ahoppen Oct 23, 2024
81001ac
Merge pull request #77175 from simanerush/se-0449-flag
simanerush Oct 23, 2024
edd9955
[Runtime] Fix SwiftError handling in CVW runtime
drexin Oct 24, 2024
8565c28
demangler: correctly handle function attributes when there is an unma…
eeckstein Oct 23, 2024
b8a91c9
embedded: make sure to de-serialize vtable/wtable methods before tryi…
eeckstein Oct 24, 2024
512e6b3
Merge pull request #77191 from tshortli/swift6-nonexhaustive-switch-w…
tshortli Oct 24, 2024
e030e37
[Backtracing] Fix macro test.
al45tair Oct 24, 2024
b6247b0
Merge pull request #77200 from al45tair/eng/PR-137551812-fix2
aschwaighofer Oct 24, 2024
80190ad
Merge pull request #77184 from eeckstein/fix-demangler
eeckstein Oct 24, 2024
d0ff56b
Merge pull request #70564 from artemcm/ExplicitBuildClangTargetIRGen
artemcm Oct 24, 2024
11a0a7b
Merge pull request #77157 from gottesmm/pr-c925512997373e4967384247d4…
aschwaighofer Oct 24, 2024
cd83ee1
Merge pull request #77198 from eeckstein/fix-vtable-specialization
eeckstein Oct 24, 2024
c67b0c7
Merge pull request #77197 from drexin/wip-138085348
drexin Oct 24, 2024
5190d98
Merge pull request #77178 from slavapestov/misc-solver-cleanups
slavapestov Oct 24, 2024
746517c
Merge remote-tracking branch 'origin/main' into manually-merge-main-t…
bnbarham Oct 24, 2024
af53b3f
[IRGen] Fix up test for rebranch
bnbarham Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ To switch to this template when drafting a pull request in a [swiftlang](https:/
### Commit Access

Commit access is granted to contributors with a track record of submitting high-quality changes.
If you would like commit access, please send an email to [the code owners list]([email protected]) with the GitHub user name that you want to use and a list of 5 non-trivial pull requests that were accepted without modifications.
If you would like commit access, please send an email to [the code owners list](mailto:[email protected]) with the GitHub user name that you want to use and a list of 5 non-trivial pull requests that were accepted without modifications.

Once you’ve been granted commit access, you will be able to commit to all of the GitHub repositories that host Swift.org projects.
To verify that your commit access works, please make a test commit (for example, change a comment or add a blank line). The following policies apply to users with commit access:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private struct VTableSpecializer {
let methodSubs = classContextSubs.getMethodSubstitutions(for: entry.implementation)

guard !methodSubs.conformances.contains(where: {!$0.isValid}),
context.loadFunction(function: entry.implementation, loadCalleesRecursively: true),
let specializedMethod = context.specialize(function: entry.implementation, for: methodSubs) else
{
context.diagnosticEngine.diagnose(entry.methodDecl.location.sourceLoc, .non_final_generic_class_function)
Expand Down Expand Up @@ -125,6 +126,7 @@ func specializeWitnessTable(forConformance conformance: Conformance,
let methodSubs = conformance.specializedSubstitutions.getMethodSubstitutions(for: origMethod)

guard !methodSubs.conformances.contains(where: {!$0.isValid}),
context.loadFunction(function: origMethod, loadCalleesRecursively: true),
let specializedMethod = context.specialize(function: origMethod, for: methodSubs) else
{
context.diagnosticEngine.diagnose(errorLocation.sourceLoc, .cannot_specialize_witness_method, requirement)
Expand Down
1 change: 1 addition & 0 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ Types
type ::= 'Bp' // Builtin.RawPointer
type ::= 'Bt' // Builtin.SILToken
type ::= type 'Bv' NATURAL '_' // Builtin.Vec<n>x<type>
type ::= type type 'BV' // Builtin.FixedArray<N, T>
type ::= 'Bw' // Builtin.Word
type ::= function-signature 'c' // function type (escaping)
type ::= function-signature 'X' FUNCTION-KIND // special function type
Expand Down
21 changes: 21 additions & 0 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,27 @@ struct TargetMetatypeMetadata : public TargetMetadata<Runtime> {
};
using MetatypeMetadata = TargetMetatypeMetadata<InProcess>;

/// The structure of `Builtin.FixedArray` type metadata.
template <typename Runtime>
struct TargetFixedArrayTypeMetadata : public TargetMetadata<Runtime> {
using StoredPointerDifference = typename Runtime::StoredPointerDifference;

StoredPointerDifference Count;
ConstTargetMetadataPointer<Runtime, swift::TargetMetadata> Element;

// Returns the number of elements for which storage is reserved.
// A type that is instantiated with negative size cannot have values
// instantiated, so is laid out with zero size like an uninhabited type.
StoredPointerDifference getRealizedCount() const {
return Count < 0 ? 0 : Count;
}

static bool classof(const TargetMetadata<Runtime> *metadata) {
return metadata->getKind() == MetadataKind::FixedArray;
}
};
using FixedArrayTypeMetadata = TargetFixedArrayTypeMetadata<InProcess>;

/// The structure of tuple type metadata.
template <typename Runtime>
struct TargetTupleTypeMetadata : public TargetMetadata<Runtime> {
Expand Down
5 changes: 4 additions & 1 deletion include/swift/ABI/MetadataKind.def
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ NOMINALTYPEMETADATAKIND(Class, 0)
NOMINALTYPEMETADATAKIND(Struct, 0 | MetadataKindIsNonHeap)

/// An enum type.
/// If we add reference enums, that needs to go here.
NOMINALTYPEMETADATAKIND(Enum, 1 | MetadataKindIsNonHeap)

/// An optional type.
Expand Down Expand Up @@ -80,6 +79,10 @@ METADATAKIND(ExistentialMetatype, 6 | MetadataKindIsRuntimePrivate | MetadataKin
/// An extended existential type.
METADATAKIND(ExtendedExistential, 7 | MetadataKindIsRuntimePrivate | MetadataKindIsNonHeap)

/// A `Builtin.FixedArray`.
METADATAKIND(FixedArray, 8 | MetadataKindIsRuntimePrivate | MetadataKindIsNonHeap)


/// A heap-allocated local variable using statically-generated metadata.
METADATAKIND(HeapLocalVariable, 0 | MetadataKindIsNonType)

Expand Down
7 changes: 7 additions & 0 deletions include/swift/AST/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,13 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(DistributedActorAsAnyActor, "distributedActor
/// lowered away at IRGen, no sooner.
BUILTIN_MISC_OPERATION_WITH_SILGEN(AddressOfRawLayout, "addressOfRawLayout", "n", Special)

/// emplace<T>((Builtin.RawPointer) -> Void) -> T
///
/// Passes a pointer to an uninitialized result value to the given function,
/// which must initialize the memory before finishing execution. The value in
/// memory becomes the result of the call.
BUILTIN_SIL_OPERATION(Emplace, "emplace", Special)

/// Builtins for instrumentation added by sanitizers during SILGen.
#ifndef BUILTIN_SANITIZER_OPERATION
#define BUILTIN_SANITIZER_OPERATION(Id, Name, Attrs) BUILTIN(Id, Name, Attrs)
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ ERROR(static_var_decl_global_scope,none,
(StaticSpellingKind))
ERROR(expected_getset_in_protocol,none,
"expected get or set in a protocol property", ())
ERROR(expected_getreadset_in_protocol,none,
"expected get, read, or set in a protocol property", ())
ERROR(unexpected_getset_implementation_in_protocol,none,
"protocol property %0 cannot have a default implementation specified "
"here; use extension instead", (StringRef))
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -4641,6 +4641,8 @@ ERROR(cannot_explicitly_specialize_function,none,
"cannot explicitly specialize %kind0", (ValueDecl *))
ERROR(not_a_generic_type,none,
"cannot specialize non-generic type %0", (Type))
ERROR(invalid_generic_builtin_type,none,
"invalid generic arguments to builtin type %0", (Type))
ERROR(not_a_generic_macro,none,
"cannot specialize a non-generic external macro %0", (const ValueDecl *))
ERROR(protocol_declares_unknown_primary_assoc_type,none,
Expand Down
22 changes: 13 additions & 9 deletions include/swift/AST/ExistentialLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines the ExistentialLayout struct.
// The ExistentialLayout struct describes the in-memory layout of an existential
// type.
//
// It flattens and canonicalizes protocol compositions, and also expands defaults
// for invertible protocols.
//
//===----------------------------------------------------------------------===//

Expand All @@ -33,7 +37,6 @@ struct ExistentialLayout {
hasExplicitAnyObject = false;
containsObjCProtocol = false;
containsSwiftProtocol = false;
containsParameterized = false;
representsAnyObject = false;
}

Expand All @@ -53,9 +56,6 @@ struct ExistentialLayout {
/// Whether any protocol members require a witness table.
bool containsSwiftProtocol : 1;

/// Whether any protocol members are parameterized.s
bool containsParameterized : 1;

/// Whether this layout is the canonical layout for plain-old 'AnyObject'.
bool representsAnyObject : 1;

Expand Down Expand Up @@ -105,14 +105,18 @@ struct ExistentialLayout {
/// calling this on a temporary is likely to be incorrect.
ArrayRef<ProtocolDecl*> getProtocols() const && = delete;

ArrayRef<ParameterizedProtocolType *> getParameterizedProtocols() const & {
return parameterized;
}
/// The returned ArrayRef points to internal storage, so
/// calling this on a temporary is likely to be incorrect.
ArrayRef<ProtocolDecl*> getParameterizedProtocols() const && = delete;

LayoutConstraint getLayoutConstraint() const;

private:
SmallVector<ProtocolDecl *, 4> protocols;

/// Zero or more primary associated type requirements from a
/// ParameterizedProtocolType
ArrayRef<Type> sameTypeRequirements;
SmallVector<ParameterizedProtocolType *, 4> parameterized;
};

}
Expand Down
13 changes: 13 additions & 0 deletions include/swift/AST/TypeDifferenceVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ class CanTypeDifferenceVisitor : public CanTypePairVisitor<Impl, bool> {
return asImpl().visitDifferentTypeStructure(type1, type2);
return asImpl().visit(type1.getElementType(), type2.getElementType());
}

bool visitBuiltinUnboundGenericType(CanBuiltinUnboundGenericType type1,
CanBuiltinUnboundGenericType type2) {
return asImpl().visitDifferentTypeStructure(type1, type2);
}

bool visitBuiltinFixedArrayType(CanBuiltinFixedArrayType type1,
CanBuiltinFixedArrayType type2) {
if (asImpl().visit(type1->getSize(), type2->getSize())) {
return true;
}
return asImpl().visit(type1->getElementType(), type2->getElementType());
}

bool visitPackType(CanPackType type1, CanPackType type2) {
return visitComponentArray(type1, type2,
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/TypeMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class TypeMatcher {
TRIVIAL_CASE(BuiltinIntegerType)
TRIVIAL_CASE(BuiltinFloatType)
TRIVIAL_CASE(BuiltinVectorType)
TRIVIAL_CASE(BuiltinUnboundGenericType)
TRIVIAL_CASE(BuiltinFixedArrayType)
TRIVIAL_CASE(IntegerType)
#define SINGLETON_TYPE(SHORT_ID, ID) TRIVIAL_CASE(ID##Type)
#include "swift/AST/TypeNodes.def"
Expand Down
50 changes: 35 additions & 15 deletions include/swift/AST/TypeNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
/// This type is a builtin type. The default behavior is
/// ALWAYS_CANONICAL_TYPE(id, parent).

/// BUILTIN_CONCRETE_TYPE(id, parent)
/// This type is a builtin type without generic parameters. The default
/// behavior is BUILTIN_TYPE(id, parent).

/// BUILTIN_GENERIC_TYPE(id, parent)
/// This type is a builtin type with generic parameters. The default
/// behavior is BUILTIN_TYPE(id, parent).

/// SUGARED_TYPE(id, parent)
/// This type is never canonical. It provides an efficient accessor,
/// getSinglyDesugaredType(), which removes one level of sugar. This
Expand Down Expand Up @@ -72,6 +80,14 @@
#define BUILTIN_TYPE(id, parent) ALWAYS_CANONICAL_TYPE(id, parent)
#endif

#ifndef BUILTIN_CONCRETE_TYPE
#define BUILTIN_CONCRETE_TYPE(id, parent) BUILTIN_TYPE(id, parent)
#endif

#ifndef BUILTIN_GENERIC_TYPE
#define BUILTIN_GENERIC_TYPE(id, parent) BUILTIN_TYPE(id, parent)
#endif

#ifndef SUGARED_TYPE
#define SUGARED_TYPE(id, parent) TYPE(id, parent)
#endif
Expand Down Expand Up @@ -111,22 +127,24 @@ UNCHECKED_TYPE(Unresolved, Type)
UNCHECKED_TYPE(Placeholder, Type)
ABSTRACT_TYPE(Builtin, Type)
ABSTRACT_TYPE(AnyBuiltinInteger, BuiltinType)
BUILTIN_TYPE(BuiltinInteger, AnyBuiltinIntegerType)
BUILTIN_TYPE(BuiltinIntegerLiteral, AnyBuiltinIntegerType)
BUILTIN_CONCRETE_TYPE(BuiltinInteger, AnyBuiltinIntegerType)
BUILTIN_CONCRETE_TYPE(BuiltinIntegerLiteral, AnyBuiltinIntegerType)
TYPE_RANGE(AnyBuiltinInteger, BuiltinInteger, BuiltinIntegerLiteral)
BUILTIN_TYPE(BuiltinExecutor, BuiltinType)
BUILTIN_TYPE(BuiltinFloat, BuiltinType)
BUILTIN_TYPE(BuiltinJob, BuiltinType)
BUILTIN_TYPE(BuiltinPackIndex, BuiltinType)
BUILTIN_TYPE(BuiltinRawPointer, BuiltinType)
BUILTIN_TYPE(BuiltinRawUnsafeContinuation, BuiltinType)
BUILTIN_TYPE(BuiltinNativeObject, BuiltinType)
BUILTIN_TYPE(BuiltinBridgeObject, BuiltinType)
BUILTIN_TYPE(BuiltinUnsafeValueBuffer, BuiltinType)
BUILTIN_TYPE(BuiltinDefaultActorStorage, BuiltinType)
BUILTIN_TYPE(BuiltinNonDefaultDistributedActorStorage, BuiltinType)
BUILTIN_TYPE(BuiltinVector, BuiltinType)
TYPE_RANGE(Builtin, BuiltinInteger, BuiltinVector)
BUILTIN_CONCRETE_TYPE(BuiltinExecutor, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinFloat, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinJob, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinPackIndex, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinRawPointer, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinRawUnsafeContinuation, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinNativeObject, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinBridgeObject, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinUnsafeValueBuffer, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinDefaultActorStorage, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinNonDefaultDistributedActorStorage, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinVector, BuiltinType)
BUILTIN_GENERIC_TYPE(BuiltinFixedArray, BuiltinType)
BUILTIN_CONCRETE_TYPE(BuiltinUnboundGeneric, BuiltinType)
TYPE_RANGE(Builtin, BuiltinInteger, BuiltinUnboundGeneric)
TYPE(Tuple, Type)
ABSTRACT_TYPE(ReferenceStorage, Type)
#define REF_STORAGE(Name, ...) \
Expand Down Expand Up @@ -228,6 +246,8 @@ SINGLETON_TYPE(SILToken, SILToken)
#undef UNCHECKED_TYPE
#undef ARTIFICIAL_TYPE
#undef SUGARED_TYPE
#undef BUILTIN_GENERIC_TYPE
#undef BUILTIN_CONCRETE_TYPE
#undef BUILTIN_TYPE
#undef ALWAYS_CANONICAL_TYPE
#undef ALWAYS_CANONICAL_ARTIFICIAL_TYPE
Expand Down
27 changes: 26 additions & 1 deletion include/swift/AST/TypeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TypeTransform {
TypeBase *base = t.getPointer();

switch (base->getKind()) {
#define BUILTIN_TYPE(Id, Parent) \
#define BUILTIN_CONCRETE_TYPE(Id, Parent) \
case TypeKind::Id:
#define TYPE(Id, Parent)
#include "swift/AST/TypeNodes.def"
Expand All @@ -120,6 +120,31 @@ case TypeKind::Id:
case TypeKind::Integer:
return t;

case TypeKind::BuiltinFixedArray: {
auto bfaTy = cast<BuiltinFixedArrayType>(base);

Type transSize = doIt(bfaTy->getSize(),
TypePosition::Invariant);
if (!transSize) {
return Type();
}

Type transElement = doIt(bfaTy->getElementType(),
TypePosition::Invariant);
if (!transElement) {
return Type();
}

CanType canTransSize = transSize->getCanonicalType();
CanType canTransElement = transElement->getCanonicalType();
if (canTransSize != bfaTy->getSize()
|| canTransElement != bfaTy->getElementType()) {
return BuiltinFixedArrayType::get(canTransSize, canTransElement);
}

return bfaTy;
}

case TypeKind::PrimaryArchetype:
case TypeKind::PackArchetype: {
auto *archetype = cast<ArchetypeType>(base);
Expand Down
Loading