Skip to content

Commit 6095fd3

Browse files
committed
SILGen: Use getABIMembers() instead of getMembers() in a couple of spots
1 parent e53bd7f commit 6095fd3

File tree

6 files changed

+43
-45
lines changed

6 files changed

+43
-45
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,16 +1034,13 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
10341034
void emitType() {
10351035
SGM.emitLazyConformancesForType(theType);
10361036

1037+
for (Decl *member : theType->getABIMembers())
1038+
visit(member);
1039+
10371040
// Build a vtable if this is a class.
10381041
if (auto theClass = dyn_cast<ClassDecl>(theType)) {
1039-
for (Decl *member : theClass->getABIMembers())
1040-
visit(member);
1041-
10421042
SILGenVTable genVTable(SGM, theClass);
10431043
genVTable.emitVTable();
1044-
} else {
1045-
for (Decl *member : theType->getMembers())
1046-
visit(member);
10471044
}
10481045

10491046
// Build a default witness table if this is a protocol that needs one.
@@ -1178,7 +1175,7 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
11781175

11791176
/// Emit SIL functions for all the members of the extension.
11801177
void emitExtension(ExtensionDecl *e) {
1181-
for (Decl *member : e->getMembers())
1178+
for (Decl *member : e->getABIMembers())
11821179
visit(member);
11831180

11841181
if (!isa<ProtocolDecl>(e->getExtendedNominal())) {

test/IRGen/enum_derived.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ enum E {
2222
// CHECK: %2 = icmp eq i8 %0, %1
2323
// CHECK: ret i1 %2
2424

25-
// Check for the presence of the hashValue getter, calling Hasher.init() and
26-
// Hasher.finalize().
27-
28-
// CHECK-NORMAL-LABEL:define hidden swiftcc i{{.*}} @"$s12enum_derived1EO9hashValueSivg"(i8 %0)
29-
// CHECK-TESTABLE-LABEL:define{{( dllexport)?}}{{( protected)?}} swiftcc i{{.*}} @"$s12enum_derived1EO9hashValueSivg"(i8 %0)
30-
// CHECK: call swiftcc void @"$ss6HasherV5_seedABSi_tcfC"(%Ts6HasherV* {{.*}})
31-
// CHECK: call swiftcc i{{[0-9]+}} @"$ss6HasherV9_finalizeSiyF"(%Ts6HasherV* {{.*}})
32-
// CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
33-
3425
// Check if the hash(into:) method can be compiled to a simple zext instruction
3526
// followed by a call to Hasher._combine(_:).
3627

@@ -40,6 +31,15 @@ enum E {
4031
// CHECK: tail call swiftcc void @"$ss6HasherV8_combineyySuF"(i{{.*}} [[V]], %Ts6HasherV*
4132
// CHECK: ret void
4233

34+
// Check for the presence of the hashValue getter, calling Hasher.init() and
35+
// Hasher.finalize().
36+
37+
// CHECK-NORMAL-LABEL:define hidden swiftcc i{{.*}} @"$s12enum_derived1EO9hashValueSivg"(i8 %0)
38+
// CHECK-TESTABLE-LABEL:define{{( dllexport)?}}{{( protected)?}} swiftcc i{{.*}} @"$s12enum_derived1EO9hashValueSivg"(i8 %0)
39+
// CHECK: call swiftcc void @"$ss6HasherV5_seedABSi_tcfC"(%Ts6HasherV* {{.*}})
40+
// CHECK: call swiftcc i{{[0-9]+}} @"$ss6HasherV9_finalizeSiyF"(%Ts6HasherV* {{.*}})
41+
// CHECK: ret i{{[0-9]+}} %{{[0-9]+}}
42+
4343
// Derived conformances from extensions
4444
// The actual enums are in Inputs/def_enum.swift
4545

test/SILGen/property_wrappers.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ func forceHasMemberwiseInit() {
8484
// CHECK: function_ref @$sSb22_builtinBooleanLiteralSbBi1__tcfC : $@convention(method) (Builtin.Int1, @thin Bool.Type) -> Bool
8585
// CHECK: return {{%.*}} : $Bool
8686

87-
// default argument 0 of HasMemberwiseInit.init(x:y:z:)
88-
// CHECK: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA_ : $@convention(thin) <T where T : DefaultInit> () -> Wrapper<Bool>
89-
90-
// default argument 1 of HasMemberwiseInit.init(x:y:z:)
91-
// CHECK: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA0_ : $@convention(thin) <T where T : DefaultInit> () -> @out T {
92-
93-
// default argument 2 of HasMemberwiseInit.init(x:y:z:)
94-
// CHECK: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA1_ : $@convention(thin) <T where T : DefaultInit> () -> WrapperWithInitialValue<Int> {
95-
96-
9787
// HasMemberwiseInit.init()
9888
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitVACyxGycfC : $@convention(method) <T where T : DefaultInit> (@thin HasMemberwiseInit<T>.Type) -> @out HasMemberwiseInit<T> {
9989

@@ -119,6 +109,17 @@ func forceHasMemberwiseInit() {
119109

120110
// CHECK: return
121111

112+
113+
// default argument 0 of HasMemberwiseInit.init(x:y:z:)
114+
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA_ : $@convention(thin) <T where T : DefaultInit> () -> Wrapper<Bool>
115+
116+
// default argument 1 of HasMemberwiseInit.init(x:y:z:)
117+
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA0_ : $@convention(thin) <T where T : DefaultInit> () -> @out T {
118+
119+
// default argument 2 of HasMemberwiseInit.init(x:y:z:)
120+
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers17HasMemberwiseInitV1x1y1zACyxGAA7WrapperVySbG_xAA0F16WithInitialValueVySiGtcfcfA1_ : $@convention(thin) <T where T : DefaultInit> () -> WrapperWithInitialValue<Int> {
121+
122+
122123
// Non-generic struct with private property wrapper
123124
struct HasMemberwiseInitWithPrivateWrapper {
124125
@WrapperWithInitialValue
@@ -412,7 +413,7 @@ struct CompositionMembers {
412413
// CHECK-LABEL: sil hidden [transparent] [ossa] @$s17property_wrappers18CompositionMembersV3_p233_{{.*}}8WrapperAVyAA0N1BVyAA0N1CVySSGGGvpfi : $@convention(thin) () -> @owned Optional<String> {
413414
// CHECK: %0 = string_literal utf8 "Hello"
414415

415-
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers18CompositionMembersV2p12p2ACSiSg_SSSgtcfC : $@convention(method) (Optional<Int>, @owned Optional<String>, @thin CompositionMembers.Type) -> @owned CompositionMembers
416+
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers18CompositionMembersV2p12p2ACSiSg_SSSgtcfcfA0_ : $@convention(thin) () -> @owned Optional<String> {
416417
// CHECK: s17property_wrappers18CompositionMembersV3_p233_{{.*}}8WrapperAVyAA0N1BVyAA0N1CVySSGGGvpfi
417418

418419
}

test/SILGen/synthesized_conformance_class.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class Nonfinal<T> {
5555
// Make sure that CodingKeys members are actually emitted.
5656

5757
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}21__derived_enum_equalsySbAFyx_G_AHtFZ : $@convention(method) <T> (Final<T>.CodingKeys, Final<T>.CodingKeys, @thin Final<T>.CodingKeys.Type) -> Bool {
58-
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}9hashValueSivg : $@convention(method) <T> (Final<T>.CodingKeys) -> Int {
5958
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}4hash4intoys6HasherVz_tF : $@convention(method) <T> (@inout Hasher, Final<T>.CodingKeys) -> () {
60-
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}11stringValueSSvg : $@convention(method) <T> (Final<T>.CodingKeys) -> @owned String {
6159
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}11stringValueAFyx_GSgSS_tcfC : $@convention(method) <T> (@owned String, @thin Final<T>.CodingKeys.Type) -> Optional<Final<T>.CodingKeys> {
62-
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}8intValueSiSgvg : $@convention(method) <T> (Final<T>.CodingKeys) -> Optional<Int> {
6360
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}8intValueAFyx_GSgSi_tcfC : $@convention(method) <T> (Int, @thin Final<T>.CodingKeys.Type) -> Optional<Final<T>.CodingKeys> {
61+
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}9hashValueSivg : $@convention(method) <T> (Final<T>.CodingKeys) -> Int {
62+
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}8intValueSiSgvg : $@convention(method) <T> (Final<T>.CodingKeys) -> Optional<Int> {
63+
// CHECK-LABEL: sil private [ossa] @$s29synthesized_conformance_class5FinalC10CodingKeys{{.*}}11stringValueSSvg : $@convention(method) <T> (Final<T>.CodingKeys) -> @owned String {
6464

6565
extension Final: Encodable where T: Encodable {}
6666
// CHECK-LABEL: // Final<A>.encode(to:)

test/SILGen/synthesized_conformance_enum.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@ extension Enum: Equatable where T: Equatable {}
4141
// CHECK-RESILIENT-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASQRzlE2eeoiySbACyxG_AEtFZ : $@convention(method) <T where T : Equatable> (@in_guaranteed Enum<T>, @in_guaranteed Enum<T>, @thin Enum<T>.Type) -> Bool {
4242

4343
extension Enum: Hashable where T: Hashable {}
44-
// CHECK-LABEL: // Enum<A>.hashValue.getter
45-
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASHRzlE9hashValueSivg : $@convention(method) <T where T : Hashable> (@in_guaranteed Enum<T>) -> Int {
46-
4744
// CHECK-LABEL: // Enum<A>.hash(into:)
4845
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASHRzlE4hash4intoys6HasherVz_tF : $@convention(method) <T where T : Hashable> (@inout Hasher, @in_guaranteed Enum<T>) -> () {
4946

50-
extension Enum: Codable where T: Codable {}
51-
// CHECK-LABEL: // Enum<A>.init(from:)
52-
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASeRzSERzlE4fromACyxGs7Decoder_p_tKcfC : $@convention(method) <T where T : Decodable, T : Encodable> (@in Decoder, @thin Enum<T>.Type) -> (@out Enum<T>, @error Error)
47+
// CHECK-LABEL: // Enum<A>.hashValue.getter
48+
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASHRzlE9hashValueSivg : $@convention(method) <T where T : Hashable> (@in_guaranteed Enum<T>) -> Int {
5349

50+
extension Enum: Codable where T: Codable {}
5451
// CHECK-LABEL: // Enum<A>.encode(to:)
5552
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASeRzSERzlE6encode2toys7Encoder_p_tKF : $@convention(method) <T where T : Decodable, T : Encodable> (@in_guaranteed Encoder, @in_guaranteed Enum<T>) -> @error Error {
5653

54+
// CHECK-LABEL: // Enum<A>.init(from:)
55+
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum4EnumOAASeRzSERzlE4fromACyxGs7Decoder_p_tKcfC : $@convention(method) <T where T : Decodable, T : Encodable> (@in Decoder, @thin Enum<T>.Type) -> (@out Enum<T>, @error Error)
56+
5757
extension NoValues: CaseIterable {}
5858
// CHECK-LABEL: // static NoValues.allCases.getter
5959
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum8NoValuesO8allCasesSayACGvgZ : $@convention(method) (@thin NoValues.Type) -> @owned Array<NoValues> {
6060

6161
extension NoValues: Codable {}
62-
// CHECK-LABEL: // NoValues.init(from:)
63-
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum8NoValuesO4fromACs7Decoder_p_tKcfC : $@convention(method) (@in Decoder, @thin NoValues.Type) -> (NoValues, @error Error)
64-
6562
// CHECK-LABEL: // NoValues.encode(to:)
6663
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum8NoValuesO6encode2toys7Encoder_p_tKF : $@convention(method) (@in_guaranteed Encoder, NoValues) -> @error Error {
6764

65+
// CHECK-LABEL: // NoValues.init(from:)
66+
// CHECK-NEXT: sil hidden [ossa] @$s28synthesized_conformance_enum8NoValuesO4fromACs7Decoder_p_tKcfC : $@convention(method) (@in Decoder, @thin NoValues.Type) -> (NoValues, @error Error)
67+
6868
// Witness tables for Enum
6969

7070
// CHECK-LABEL: sil_witness_table hidden <T where T : Equatable> Enum<T>: Equatable module synthesized_conformance_enum {

test/SILGen/synthesized_conformance_struct.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ extension Struct: Equatable where T: Equatable {}
4040
// CHECK-RESILIENT-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASQRzlE2eeoiySbACyxG_AEtFZ : $@convention(method) <T where T : Equatable> (@in_guaranteed Struct<T>, @in_guaranteed Struct<T>, @thin Struct<T>.Type) -> Bool {
4141

4242
extension Struct: Hashable where T: Hashable {}
43-
// CHECK-LABEL: // Struct<A>.hashValue.getter
44-
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASHRzlE9hashValueSivg : $@convention(method) <T where T : Hashable> (@in_guaranteed Struct<T>) -> Int {
45-
4643
// CHECK-LABEL: // Struct<A>.hash(into:)
4744
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASHRzlE4hash4intoys6HasherVz_tF : $@convention(method) <T where T : Hashable> (@inout Hasher, @in_guaranteed Struct<T>) -> () {
4845

49-
extension Struct: Codable where T: Codable {}
50-
// CHECK-LABEL: // Struct<A>.init(from:)
51-
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASeRzSERzlE4fromACyxGs7Decoder_p_tKcfC : $@convention(method) <T where T : Decodable, T : Encodable> (@in Decoder, @thin Struct<T>.Type) -> (@out Struct<T>, @error Error)
46+
// CHECK-LABEL: // Struct<A>.hashValue.getter
47+
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASHRzlE9hashValueSivg : $@convention(method) <T where T : Hashable> (@in_guaranteed Struct<T>) -> Int {
5248

49+
extension Struct: Codable where T: Codable {}
5350
// CHECK-LABEL: // Struct<A>.encode(to:)
5451
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASeRzSERzlE6encode2toys7Encoder_p_tKF : $@convention(method) <T where T : Decodable, T : Encodable> (@in_guaranteed Encoder, @in_guaranteed Struct<T>) -> @error Error {
5552

53+
// CHECK-LABEL: // Struct<A>.init(from:)
54+
// CHECK-NEXT: sil hidden [ossa] @$s30synthesized_conformance_struct6StructVAASeRzSERzlE4fromACyxGs7Decoder_p_tKcfC : $@convention(method) <T where T : Decodable, T : Encodable> (@in Decoder, @thin Struct<T>.Type) -> (@out Struct<T>, @error Error)
55+
5656

5757
// Witness tables
5858

0 commit comments

Comments
 (0)