Skip to content

[Serialization] Serialize hasCReferences to keep linkage #33662

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 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,14 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
GenericSignatureID genericSigID;
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
isWithoutactuallyEscapingThunk, specialPurpose, inlineStrategy,
optimizationMode, subclassScope, effect, numSpecAttrs,
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
isDynamic, isExactSelfClass;
ArrayRef<uint64_t> SemanticsIDs;
SILFunctionLayout::readRecord(
scratch, rawLinkage, isTransparent, isSerialized, isThunk,
isWithoutactuallyEscapingThunk, specialPurpose, inlineStrategy,
optimizationMode, subclassScope, effect, numSpecAttrs,
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
clangNodeOwnerID, SemanticsIDs);
Expand Down Expand Up @@ -639,6 +639,7 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
fn->setOptimizationMode(OptimizationMode(optimizationMode));
fn->setAlwaysWeakImported(isWeakImported);
fn->setClassSubclassScope(SubclassScope(subclassScope));
fn->setHasCReferences(bool(hasCReferences));

llvm::VersionTuple available;
DECODE_VER_TUPLE(available);
Expand Down Expand Up @@ -2824,14 +2825,14 @@ bool SILDeserializer::hasSILFunction(StringRef Name,
GenericSignatureID genericSigID;
unsigned rawLinkage, isTransparent, isSerialized, isThunk,
isWithoutactuallyEscapingThunk, isGlobal, inlineStrategy,
optimizationMode, subclassScope, effect, numSpecAttrs,
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
isDynamic, isExactSelfClass;
ArrayRef<uint64_t> SemanticsIDs;
SILFunctionLayout::readRecord(
scratch, rawLinkage, isTransparent, isSerialized, isThunk,
isWithoutactuallyEscapingThunk, isGlobal, inlineStrategy,
optimizationMode, subclassScope, effect, numSpecAttrs,
optimizationMode, subclassScope, hasCReferences, effect, numSpecAttrs,
hasQualifiedOwnership, isWeakImported, LIST_VER_TUPLE_PIECES(available),
isDynamic, isExactSelfClass, funcTyID, replacedFunctionID, genericSigID,
clangOwnerID, SemanticsIDs);
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 575; // GlobalInitOnceFunction SILFunction purpose
const uint16_t SWIFTMODULE_VERSION_MINOR = 576; // hasCReferences

/// A standard hash seed used for all string hashes in a serialized module.
///
Expand Down
1 change: 1 addition & 0 deletions lib/Serialization/SILFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ namespace sil_block {
BCFixed<2>, // inlineStrategy
BCFixed<2>, // optimizationMode
BCFixed<2>, // classSubclassScope
BCFixed<1>, // hasCReferences
BCFixed<3>, // side effect info.
BCVBR<8>, // number of specialize attributes
BCFixed<1>, // has qualified ownership
Expand Down
6 changes: 3 additions & 3 deletions lib/Serialization/SerializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) {
Out, ScratchRecord, abbrCode, toStableSILLinkage(Linkage),
(unsigned)F.isTransparent(), (unsigned)F.isSerialized(),
(unsigned)F.isThunk(), (unsigned)F.isWithoutActuallyEscapingThunk(),
(unsigned)F.getSpecialPurpose(),
(unsigned)F.getInlineStrategy(), (unsigned)F.getOptimizationMode(),
(unsigned)F.getClassSubclassScope(), (unsigned)F.getEffectsKind(),
(unsigned)F.getSpecialPurpose(), (unsigned)F.getInlineStrategy(),
(unsigned)F.getOptimizationMode(), (unsigned)F.getClassSubclassScope(),
(unsigned)F.hasCReferences(), (unsigned)F.getEffectsKind(),
(unsigned)numSpecAttrs, (unsigned)F.hasOwnership(),
F.isAlwaysWeakImported(), LIST_VER_TUPLE_PIECES(available),
(unsigned)F.isDynamicallyReplaceable(), (unsigned)F.isExactSelfClass(),
Expand Down
12 changes: 12 additions & 0 deletions test/Serialization/cdecl_attr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)
// Ensure .swift -> .ll
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s

// Ensure .swift -> .sib -> .ll
// RUN: %target-swift-frontend -emit-sib %s -o %t/cdecl_attr.sib
// RUN: %target-swift-frontend -emit-ir %t/cdecl_attr.sib | %FileCheck %s

// CHECK: define hidden {{.*}} @foo

@_cdecl("foo")
func foo() {}