diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index b2cfae7bfd405..b4c536e4f7355 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -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 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); @@ -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); @@ -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 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); diff --git a/lib/Serialization/ModuleFormat.h b/lib/Serialization/ModuleFormat.h index 2b95150e58ff2..a3e1f36a59277 100644 --- a/lib/Serialization/ModuleFormat.h +++ b/lib/Serialization/ModuleFormat.h @@ -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. /// diff --git a/lib/Serialization/SILFormat.h b/lib/Serialization/SILFormat.h index c1178d5f551ad..696f06b0d82fa 100644 --- a/lib/Serialization/SILFormat.h +++ b/lib/Serialization/SILFormat.h @@ -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 diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index da46d36dd1b0a..fe1c2dd967a96 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -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(), diff --git a/test/Serialization/cdecl_attr.swift b/test/Serialization/cdecl_attr.swift new file mode 100644 index 0000000000000..aa3975a738b97 --- /dev/null +++ b/test/Serialization/cdecl_attr.swift @@ -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() {}