Skip to content

Commit 413eba8

Browse files
authored
Merge pull request #33662 from kateinoigakukun/katei/serialize-has-cref
[Serialization] Serialize hasCReferences to keep linkage
2 parents 679aaca + 992c383 commit 413eba8

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,14 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
511511
GenericSignatureID genericSigID;
512512
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
513513
isWithoutactuallyEscapingThunk, specialPurpose, inlineStrategy,
514-
optimizationMode, subclassScope, effect, numSpecAttrs,
514+
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
515515
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, specialPurpose, inlineStrategy,
521-
optimizationMode, subclassScope, effect, numSpecAttrs,
521+
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
522522
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
523523
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
524524
clangNodeOwnerID, SemanticsIDs);
@@ -639,6 +639,7 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
639639
fn->setOptimizationMode(OptimizationMode(optimizationMode));
640640
fn->setAlwaysWeakImported(isWeakImported);
641641
fn->setClassSubclassScope(SubclassScope(subclassScope));
642+
fn->setHasCReferences(bool(hasCReferences));
642643

643644
llvm::VersionTuple available;
644645
DECODE_VER_TUPLE(available);
@@ -2824,14 +2825,14 @@ bool SILDeserializer::hasSILFunction(StringRef Name,
28242825
GenericSignatureID genericSigID;
28252826
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
28262827
isWithoutactuallyEscapingThunk, isGlobal, inlineStrategy,
2827-
optimizationMode, subclassScope, effect, numSpecAttrs,
2828+
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
28282829
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
28292830
isDynamic, isExactSelfClass;
28302831
ArrayRef<uint64_t> SemanticsIDs;
28312832
SILFunctionLayout::readRecord(
28322833
scratch, rawLinkage, isTransparent, isSerialized, isThunk,
28332834
isWithoutactuallyEscapingThunk, isGlobal, inlineStrategy,
2834-
optimizationMode, subclassScope, effect, numSpecAttrs,
2835+
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
28352836
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
28362837
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
28372838
clangOwnerID, SemanticsIDs);

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 = 575; // GlobalInitOnceFunction SILFunction purpose
58+
const uint16_t SWIFTMODULE_VERSION_MINOR = 576; // hasCReferences
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<2>, // inlineStrategy
282282
BCFixed<2>, // optimizationMode
283283
BCFixed<2>, // classSubclassScope
284+
BCFixed<1>, // hasCReferences
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) {
433433
Out, ScratchRecord, abbrCode, toStableSILLinkage(Linkage),
434434
(unsigned)F.isTransparent(), (unsigned)F.isSerialized(),
435435
(unsigned)F.isThunk(), (unsigned)F.isWithoutActuallyEscapingThunk(),
436-
(unsigned)F.getSpecialPurpose(),
437-
(unsigned)F.getInlineStrategy(), (unsigned)F.getOptimizationMode(),
438-
(unsigned)F.getClassSubclassScope(), (unsigned)F.getEffectsKind(),
436+
(unsigned)F.getSpecialPurpose(), (unsigned)F.getInlineStrategy(),
437+
(unsigned)F.getOptimizationMode(), (unsigned)F.getClassSubclassScope(),
438+
(unsigned)F.hasCReferences(), (unsigned)F.getEffectsKind(),
439439
(unsigned)numSpecAttrs, (unsigned)F.hasOwnership(),
440440
F.isAlwaysWeakImported(), LIST_VER_TUPLE_PIECES(available),
441441
(unsigned)F.isDynamicallyReplaceable(), (unsigned)F.isExactSelfClass(),

test/Serialization/cdecl_attr.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// Ensure .swift -> .ll
3+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
4+
5+
// Ensure .swift -> .sib -> .ll
6+
// RUN: %target-swift-frontend -emit-sib %s -o %t/cdecl_attr.sib
7+
// RUN: %target-swift-frontend -emit-ir %t/cdecl_attr.sib | %FileCheck %s
8+
9+
// CHECK: define hidden {{.*}} @foo
10+
11+
@_cdecl("foo")
12+
func foo() {}

0 commit comments

Comments
 (0)