Skip to content

Commit 4b8bbf7

Browse files
authored
Merge pull request #33279 from kateinoigakukun/katei/serialize-subclass-scope
[Serialization] Serialize subclassScope to keep linkage
2 parents bfb1e91 + 0ce2810 commit 4b8bbf7

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -511,17 +511,16 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
511511
GenericSignatureID genericSigID;
512512
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
513513
isWithoutactuallyEscapingThunk, isAsync, specialPurpose, inlineStrategy,
514-
optimizationMode, effect, numSpecAttrs, hasQualifiedOwnership,
515-
isWeakImported, LIST_VER_TUPLE_PIECES(available),
514+
optimizationMode, subclassScope, effect, numSpecAttrs,
515+
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
516516
isDynamic, isExactSelfClass;
517517
ArrayRef<uint64_t> SemanticsIDs;
518518
SILFunctionLayout::readRecord(
519519
scratch, rawLinkage, isTransparent, isSerialized, isThunk,
520520
isWithoutactuallyEscapingThunk, isAsync, specialPurpose, inlineStrategy,
521-
optimizationMode, effect, numSpecAttrs, hasQualifiedOwnership,
522-
isWeakImported, LIST_VER_TUPLE_PIECES(available),
523-
isDynamic, isExactSelfClass,
524-
funcTyID, replacedFunctionID, genericSigID,
521+
optimizationMode, subclassScope, effect, numSpecAttrs,
522+
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
523+
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
525524
clangNodeOwnerID, SemanticsIDs);
526525

527526
if (funcTyID == 0) {
@@ -645,6 +644,7 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
645644
fn->setEffectsKind(EffectsKind(effect));
646645
fn->setOptimizationMode(OptimizationMode(optimizationMode));
647646
fn->setAlwaysWeakImported(isWeakImported);
647+
fn->setClassSubclassScope(SubclassScope(subclassScope));
648648

649649
llvm::VersionTuple available;
650650
DECODE_VER_TUPLE(available);
@@ -2830,17 +2830,16 @@ bool SILDeserializer::hasSILFunction(StringRef Name,
28302830
GenericSignatureID genericSigID;
28312831
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
28322832
isWithoutactuallyEscapingThunk, isAsync, isGlobal, inlineStrategy,
2833-
optimizationMode, effect, numSpecAttrs, hasQualifiedOwnership,
2834-
isWeakImported, LIST_VER_TUPLE_PIECES(available),
2833+
optimizationMode, subclassScope, effect, numSpecAttrs,
2834+
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
28352835
isDynamic, isExactSelfClass;
28362836
ArrayRef<uint64_t> SemanticsIDs;
28372837
SILFunctionLayout::readRecord(
28382838
scratch, rawLinkage, isTransparent, isSerialized, isThunk,
28392839
isWithoutactuallyEscapingThunk, isAsync, isGlobal, inlineStrategy,
2840-
optimizationMode, effect, numSpecAttrs, hasQualifiedOwnership,
2841-
isWeakImported, LIST_VER_TUPLE_PIECES(available),
2842-
isDynamic, isExactSelfClass,
2843-
funcTyID, replacedFunctionID, genericSigID,
2840+
optimizationMode, subclassScope, effect, numSpecAttrs,
2841+
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
2842+
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
28442843
clangOwnerID, SemanticsIDs);
28452844
auto linkage = fromStableSILLinkage(rawLinkage);
28462845
if (!linkage) {

lib/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t SWIFTMODULE_VERSION_MINOR = 568; // removed UTF16
58+
const uint16_t SWIFTMODULE_VERSION_MINOR = 569; // subclass scope
5959

6060
/// A standard hash seed used for all string hashes in a serialized module.
6161
///

lib/Serialization/SILFormat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ namespace sil_block {
281281
BCFixed<3>, // specialPurpose
282282
BCFixed<2>, // inlineStrategy
283283
BCFixed<2>, // optimizationMode
284+
BCFixed<2>, // classSubclassScope
284285
BCFixed<3>, // side effect info.
285286
BCVBR<8>, // number of specialize attributes
286287
BCFixed<1>, // has qualified ownership

lib/Serialization/SerializeSIL.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) {
435435
(unsigned)F.isThunk(), (unsigned)F.isWithoutActuallyEscapingThunk(),
436436
(unsigned)F.isAsync(), (unsigned)F.getSpecialPurpose(),
437437
(unsigned)F.getInlineStrategy(), (unsigned)F.getOptimizationMode(),
438-
(unsigned)F.getEffectsKind(), (unsigned)numSpecAttrs,
439-
(unsigned)F.hasOwnership(), F.isAlwaysWeakImported(),
440-
LIST_VER_TUPLE_PIECES(available), (unsigned)F.isDynamicallyReplaceable(),
441-
(unsigned)F.isExactSelfClass(), FnID, replacedFunctionID, genericSigID,
442-
clangNodeOwnerID, SemanticsIDs);
438+
(unsigned)F.getClassSubclassScope(), (unsigned)F.getEffectsKind(),
439+
(unsigned)numSpecAttrs, (unsigned)F.hasOwnership(),
440+
F.isAlwaysWeakImported(), LIST_VER_TUPLE_PIECES(available),
441+
(unsigned)F.isDynamicallyReplaceable(), (unsigned)F.isExactSelfClass(),
442+
FnID, replacedFunctionID, genericSigID, clangNodeOwnerID, SemanticsIDs);
443443

444444
if (NoBody)
445445
return;

test/Serialization/access-level.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix DIRECT-CHECK
3+
// RUN: %target-swift-frontend -emit-sib %s -o %t/access-level.sib
4+
// RUN: %target-swift-frontend -emit-ir %t/access-level.sib | %FileCheck %s --check-prefix FROM-SIB-CHECK
5+
6+
// Ensure that the method linkage is default external when lowered from .swift directly
7+
// DIRECT-CHECK-NOT: define{{.*}}internal{{.*}}swiftcc{{.*}}void @"$s4main7VisitorC13visitExprImpl33_205B03B83823935B4865F4617387553BLLyyF"
8+
9+
// Ensure that the method linkage is default external when lowered from .swift -> .sib -> .ll
10+
// FROM-SIB-CHECK-NOT: define{{.*}}internal{{.*}}swiftcc{{.*}}void @"$s4main7VisitorC13visitExprImpl33_205B03B83823935B4865F4617387553BLLyyF"
11+
12+
open class Visitor {
13+
public func visit() {
14+
visitExprImpl()
15+
}
16+
@_optimize(none)
17+
private func visitExprImpl() {
18+
}
19+
}

0 commit comments

Comments
 (0)